c++

Displaying polymorphic classes.

I have an existing app with a command-line interface that I'm adding a GUI to. One situation that often comes up is that I have a list of objects that inherit from one class, and need to be displayed in a list, but each subclass has a slightly different way of being displayed. Not wanting to have giant switch statements everywhere usin...

Fastest way to determine whether a string contains a real or integer value

I'm trying to write a function that is able to determine whether a string contains a real or an integer value. This is the simplest solution I could think of: int containsStringAnInt(char* strg){ for (int i =0; i < strlen(strg); i++) {if (strg[i]=='.') return 0;} return 1; } But this solution is really slow when the string is lon...

Is it worth learning AMD-specific APIs?

I'm currently learning the APIs related to Intel's parallelization libraries such as TBB, MKL and IPP. I was wondering, though, whether it's also worth looking at AMD's part of the puzzle. Or would that just be a waste of time? (I must confess, I have no clue about AMD's library support - at all - so would appreciate any advice you might...

boost::filesystem::path for unicode file paths?

Is there a way to use boost::filesystem::path with unicode file paths? In particular I'd like to use it with std::wstring instead of std::string. I'm working on the windows platform and I need to sometimes process a filepath that has a unicode char in it. ...

which tool to use to view memory layout of multiple inheritance

Is there a tool that I can use to see the multiple inheritance memory layout of compiled C++ code? ...

C++ Inserting 2D array Object into another 2D array Object

In using Dev C++, I a m trying to insert a smaller 2D array object into a larger 2D array object. While attempting to achieve that, I came into compilers errors which I do not know how to solve. I attempt to insert the smaller Object by making it returning the array's name. Then I attempt to change the values inside the large array with...

C++ 2DArray Objects; Pointers and Array Problems

This problem is from a solved problem in my old question, which is from: http://stackoverflow.com/questions/394763/c-inserting-2d-array-object-into-another-2d-array-object But also created a new problem for me. Please read the question and the solution in the link to understand my problem. The solution in the previous question was to ma...

Silencing GCC warnings when using an "Uncopyable" class

I have several classes that I don't want to be copyable, some of these classes have pointer data members. To make these classes uncopyable I privately inherit the following class template: template <class T> class Uncopyable { protected: Uncopyable() {} virtual ~Uncopyable() {} private: Uncopyable(const Uncopyable &); ...

How to write an automated test for thread safety

I have a class which is not thread safe: class Foo { /* Abstract base class, code which is not thread safe */ }; Moreover, if you have foo1 and foo2 objects, you cannot call foo1->someFunc() until foo2->anotherFunc() has returned (this can happen with two threads). This is the situation and it can't be changed (a Foo subclass is...

Extern keyword and unresolved external symbols!

I drew a little graph in paint that explains my problem: But it doesn't seem to show up when I use the <img> tag after posting? Here is a direct link: http://i44.tinypic.com/103gcbk.jpg ...

How to programmatically capture a web page with forced updates.

I need to capture a web site and am looking for an appropriate library or program to do this. The website uses Java Script and pushes updates to the page and I need to capture these as well as the page itself. I am using curl to capture the page itself but I don't know how to capture the updates. Where given a choice I would use C++. Re...

RAII and smart pointers in C++

In practice with C++, what is RAII, what are smart pointers, how are these implemented in a program and what are the benefits of using RAII with smart pointers? ...

Using cmake to generate visual studio C++ project files

Hi, I am working on an open source C++ project, for code that compiles on Linux and Windows. I use cmake to build the code on Linux. For ease of dev-setup and political reasons, I must stick to visual studio project files/editor on Windows (I can't switch to Code::Blocks, for example). I see instructions to generate visual studio files...

How do you choose between a singleton and an unnamed class?

I'd use a singleton like this: Singleton* single = Singleton::instance(); single->do_it(); I'd use an unnamed class like this: single.do_it(); I feel as if the Singleton pattern has no advantage over the unnamed class other than having readable error messages. Using singletons is clumsier than using an unnamed class object: First...

Are child processes created with fork() automatically killed when the parent is killed?

I'm creating child processes with fork() in C/C++. When the parent process ends (or is killed for some reason) I want all child processes to be killed as well. Is that done automatically by the system? Or I have to do it myself? Thanks. Pre-existing similar questions: http://stackoverflow.com/questions/269494/how-can-i-cause-a-chil...

Why cannot show debug by ACE_DEBUG?

ACE_DEBUG declare #include< ace/Task.h > in source header file.I trace debug define by ACE_DEBUG((LM_ERROR, "Reader pathSetOpen : %s ",pathSetOpen); The string variable name "pathSetOpen" for show value still execute programs.But I cannot compile code. About ACE_DEBUG,It's macro for printing debug message. Compile error code. ...

Is it Wise to Spend Cash on a C++ Book Keeping in View the Upcoming C++0x?

I just purchased C++ GUI Programming with Qt4 and after reading the code samples in this book I'm beginning to realize that my knowledge of C++ is incomplete. I learned C++ two years ago from online tutorials and a couple of ebooks I downloaded, and it turns out none of these resources were good enough. Since then I haven't touched the l...

Tools, Visual Studio Setting to check uninitialized class members

I am porting a big and complex c++ server from Solaris to Windows. I am facing lots of trouble due to uninitialized member variables. On Solaris they get set to 0 value by default hence things work fine. But, on windows those member variables get garbage values assigned creating mayhem in the system. Code base is too huge to manually ch...

Classes Including Each Other in C++

Hello! I'm a C++ newbie, but I wasn't able to find the answer to this (most likely trivial) question online. I am having some trouble compiling some code where two classes include each other. To begin, should my #include statements go inside or outside of my macros? In practice, this hasn't seemed to matter. However, in this particu...

What is the best way to check for memory leaks in c++?

I'm implementing a sparse matrix with linked lists and it's not fun to manually check for leaks, any thoughts? ...