c++

Open source C/C++ Audio to text lib

Turn spoken dialogue into text-based, timecode-accurate, searchable metadata or just into text. What do I need: Open source libs Articles on using them ...

Problem with returning arguments that are const references

I know why the following does not work correclty, so I am not asking why. But I am feeling bad about it is that it seems to me that it is a very big programming hindrance. #include <iostream> #include <string> using namespace std; string ss("hello"); const string& fun(const string& s) { return s; } int main(){ const s...

C++ destruction of temporary object in an expression

Given the following code: #include <iostream> struct implicit_t { implicit_t(int x) : x_m(x) { std::cout << "ctor" << std::endl; } ~implicit_t() { std::cout << "dtor" << std::endl; } int x_m; }; std::ostream& operator<<(std::ostream& s, const implicit_t& x) { return s << x.x_m;...

Encapsulating a private enum

Previously I've defined enumerated types that are intended to be private in the header file of the class. private: enum foo { a, b, c }; However, I don't want the details of the enum exposed anymore. Is defining the enum in the implementation similar to defining class invariants? const int ClassA::bar = 3; enum ClassA::foo { a, b, ...

can two classes see each other using C++?

So I have a class A, where I want to call some class B functions. So I include "b.h". But, in class B, I want to call a class A function. If I include "a.h", it ends up in an infinite loop, right? What can I do about it? ...

Creating single EXE file for project using .Net and another external library

I have an email client created for class that we need to run as a single EXE. It is made with C++ .NET, and the external POCO library, which has a ton of DLL files... What would be the best way to make this happen? I was looking on some similarly asked questions, and some people recommended tools such as ILMerge and Ezirez, but the que...

Which version of boost should I use with c++ visual-studio-2005?

Does anyone know what version of the Boost Library to use with Visual Studio 2005? ...

Problem with cross casting in Visual Studio 2003

I am using Visual Studio 2003 to compile and run following program. There are 4 assignment operation where I expect 2 of them to run ok and 2 of them to raise exception. There is a dynamic casting inside overloaded = operator which expect to fail during non proper cross casting (Casting from Apple to Orange or Orange to Apple). But in m...

mySql Connector exception (C++ library for mysql) when inserting row into non-empty table

I have not done much database programming at all. I am working from some example code for using MySQL Connector/C++. When I run the following code I get a crash on the last line in some std::string code - but it ONLY crashes when the table is not empty. If the table is empty, it inserts the row and works fine. If the table is non emp...

Baseclass Virtual Destructor Access Violation

Sorry if this was asked already, but I had a hard time searching for destructor and access violation =) Here's C++ pseudo-code the scenario: In DLL1 (compiled with /MT) class A { public: virtual ~A() <== if "virtual" is removed, everthing works OK { } } class B : public A { public: __declspec( dllexport ) ~B() ...

passing Temporary variables to reference arg in Cons works. but not for functions in general. Why?

Consider the following code. Here, A a(B()) compiles even though the constructor is A(B& b); But print(B()) does not work. But print is also declared as print(B& b); Why this inconsistency? #include <iostream> using namespace std; class B{ public: char b; }; class A { public: B b; A(B& b); ...

Is there any open source clinic software which develop with C++?

Please recommended some good open source C++ projects, and please add your remarks on these projects Thanks ...

Jump Table Switch Case question

Hi. I am trying to understand some things about jump tables and its relationship between a switch case statement. I was told that a jump table is a O(1) structure that the compiler generates which makes lookup of values essentially about as fast as you can get. However in some cases a Hashtable/Dictionary might be faster. I was also tol...

Is it possible to use separate threads for reading and writing with Boost.Asio?

According to the Boost Documentation, having multiple threads call io_service::run() sets up a pool of threads that the IO service can use for performing asynchronous tasks. It explicitly states that all threads that have joined the pool are considered equivalent. Does this imply that it is not possible to have a separate thread for rea...

problem parsing a xml file with MSXML4 in C++

Here is my parsing code: MSXML2::IXMLDOMNodePtr pNode = m_pXmlDoc->selectSingleNode(kNameOfChild.c_str()); MSXML2::IXMLDOMNodeListPtr pIDOMNodeList = NULL; MSXML2::IXMLDOMNodePtr pIDOMNode = NULL; long numOfChildNodes= 0; BSTR bstrItemText; HRESULT hr; MSXML2::IXMLDOMElementPtr pChildNode = m_pXmlDoc->getElementsByTagName(kNameOfChild...

Handling touch detection in iPhone with C++?

I'm working on a game for the iPhone, for several reasons most of the code is in C++. I need to write a TouchesManager for my Game, I know about the methods touchesBegan: touchesEnded: and touchesMoved: I would really like to make a manager in C++ so I can subscribe some classes to this manager, so they can handle touch events in my Gam...

Types in a public c++ API

I'm writing a library and wonder what's the best practise for datatypes used in a public API. Given the funtion void foo (int bar) which expects an index to some internal array/container. What type should that be? Because an index can never be negative I could use unsigned int or size_t. Or should I stick with a plain int and assert ...

What's C++ Really Doing When I Accidently Use a Variables to Declare Array Length?

I was helping a friend with some C++ homework. I warned said friend that the kind of programming I do (PHP, Perl, Python) is pretty different from C++, and there were no guarantees I wouldn't tell horrible lies. I was able to answer his questions, but not without stumbling over my own dynamic background. While I was reacquainting myse...

Calculating the Amount of Combinations

Cheers, I know you can get the amount of combinations with the following formula (without repetition and order is not important): // Choose r from n n! / r!(n - r)! However, I don't know how to implement this with C++, since for instance with n = 52 n! = 8,0658175170943878571660636856404e+67 the number gets way too big even for un...

C++ and Thrift: Reference needed to get started

Hello, I have read about Thrift while trying to find out how to use Google Protocol Buffers. I have been searching for some reference that shows how to go about using it with a simple working example for C++. It's been frustrating not being able to find any such site. It is a bit surprising that almost all the examples use Java, a langua...