c++

Does dispatching on a Boost variant type take linear time ?

How efficient is dispatching on a boost::variant ? If it's a switch statement, it should only take O(1) time, but as far as I know, template metaprogrammign can only generate if's, which would put boost::variant dispatchs at a runtime overhead of O(n), where n = number of types in the variant. Can anyone confirm/deny/enlighten me on th...

What are the best naming conventions you've used?

I was wondering how people name variables, objects, and function names with all the combination's out there; camel-case, pascal, using underscores, all caps for statics etc.... A good naming convention that is uniform could create a quicker understanding of what the item is, leading to much faster interpretations...e.g. 'oh its all in c...

Slow C++ DirectX 2D Game

Hi, I'm new to C++ and DirectX, I come from XNA. I have developed a game like Fly The Copter. What i've done is created a class named Wall. While the game is running I draw all the walls. In XNA I stored the walls in a ArrayList and in C++ I've used vector. In XNA the game just runs fast and in C++ really slow. Here's the C++ code: void...

VS2008 Detected Dependencies - Versions

After building my project on two different machines, my setup project seems to inject microsoft_vc90_mfc_x86.asm dependencies with different versions. My local machine uses version 9.0.21022.8 while the build machine uses 9.0.30729.1. I've checked the Visual Studio versions and they are both 9.0.30729.1 SP. The build machine has some ho...

Memory leaks in Debug mode

Is there any reason for a program to leak when compiled in Debug mode and not in release? (Debug means debug informations, and compiler optimization disabled, Release means no debug info / full optimization) That's what it seems to do but I can't figure out why. Btw purify is not being helpful here ...

How do I get specific error information from GetFile()?

void GetFtpFile(LPCTSTR pszServerName, LPCTSTR pszRemoteFile, LPCTSTR pszLocalFile) { CInternetSession session(_T("My FTP Session")); CFtpConnection* pConn = NULL; pConn = session.GetFtpConnection(pszServerName); //get the file if (!pConn->GetFile(pszRemoteFile, pszLocalFile)) { //display an error } delete ...

more c++ multiple inheritance fun

Possible Duplicate: C++ pointer multi-inheritance fun. (Follow up on: http://stackoverflow.com/questions/2157104/c-pointer-multi-inheritance-fun ) I'm writing some code involving inheritance from a basic ref-counting pointer class; and some intricacies of C++ popped up. I've reduced it as follows: Suppose I have: class A{in...

Validation Framework in C++

Both Java and .Net seem to have a wealth of object validation frameworks (e.g. Commons Validator, XWork, etc.), but I've been unable to find anything similar for C++. Has anyone come across something like this, or do people typically roll their own? ...

c++ multiple-inheritance

Possible Duplicates: C++ pointer multi-inheritance fun. more c++ multiple inheritance fun This is a problem that arose from dealing with ref-counted pointer base class and threading fun. Given: class A{int x, y;}; class B{int xx, yy;}; class C: public A, public B {int z;}; C c; C* pc = &c; B* pb = CtoB(pc); A* pa = CtoA(pc...

Notify a C++ application when a change in a SQL Server table is made

I've posted this before but haven't obtained a suitable answer that fits my requirements. I'm looking for a technology to notify a C++ application when a change to a SQL Server table is made. Our middle-tier is C++ and we're not looking to move onto .NET infrastructure which means we can't use SQLDependency, or SQL Notification Servers. ...

Mentoring Junior Developers in C++

I've been tasked with trying to come up with a topic to research and present for my team to deal with areas of C++ that might be tricky for more junior developers who mainly have dealt with C coding. I was wondering if anyone had ideas for topics for these kind of talks and then if the resulting slide deck of my talks would be useful fo...

Connected Component Labeling in C++

I need to use the connected component labeling algorithm on an image in a C++ application. I can implement that myself, but I was trying to use Boost's union-find/disjoint sets implementation since it was mentioned in the union-find wiki article. I can't figure out how to create the disjoint_sets object so that it'll work with the image...

Inherit from two polymorphic classes

Given the following code class T { public: virtual ~T () {} virtual void foo () = 0; }; class U { public: U() {} ~U() {} void bar () { std::cout << "bar" << std::endl; } }; class A : public U, public T { public: void foo () { std::cout << "foo" << std::endl; } }; int main ()...

Split string into array of chars in C++

Hello, I'm writing a program that requires a string to be inputed, then broken up into individual letters. Essentially, I need help finding a way to turn "string" into ["s","t","r","i","n","g"]. The strings are also stored using the string data type instead of just an array of chars be default. I would like to keep it that way and avoid ...

How to use colors in Motif

I'm new to GUI programming in C and Linux, and I'm having a hard time with it. It seems like a fairly simple/straightforward thing, but I can't find any answers googling. I want to add a background color to a widget. XmNbackground seems to be what I want to use, but I don't understand what I set it to, like a simple color blue, how do I ...

C++ classes and nested members

I'm not sure how to call this. Basically I want to make a class with nested members. Example: ball->location->x; or ball->path->getPath(); right now I only know how to make public and private members such as ball->x; ball->findPath(); Thanks ...

Program unexpectedly quits for unknown reason (C++)

For some reason, whenever I run this program it exits at permute(permutater, length, lenth); . This doesn't happen whenever I comment out the line and the function doesn't even run. Any help? ...

What is the Java equivalent of C++'s templates?

What is the Java equivalent of C++'s templates? I know that there is an interface called Template. Is that related? ...

In C++, is it possible to forward declare a class as inheriting from another class?

I know that I can do: class Foo; but can I forward declare a class as inheriting form another, like: class Bar {}; class Foo: public Bar; ? Thanks! ...

C++: assign cin to an ifstream variable?

You know the common stdio idiom that stdin is specified by a filename of "-", e.g. if ((strcmp(fname, "-")) fp = fopen(fname); else fp = stdin; What's the best way to do this with an ifstream instance? I've received a bit of code that has an ifstream as part of a class and I'd like to add code to do the equivalent, something ...