c++

overloading delete, pure virtual func call

So i want to overload delete of a abstract virtual class. This will call deleteMe() in the derived class which is in another lib. This is to prevent error/crashes mention here http://stackoverflow.com/questions/443147/c-mix-new-delete-between-libs when i call delete me from delete in my base class, i get the error "pure virtual func cal...

Qt goes LGPL! On Windows, is it good enough to use instead of MFC?

I just read a story I was hoping to read since Nokia bought Trolltech. Qt is going LGPL in March! This is awesome news. Who uses Qt for Windows? Does it effectively replace something like MFC? Sure, I can RTFM (and to some degree I have)... but what do people USING Qt on a Windows platform think of it? I still do quite a bit of M...

What is the best unit testing tool for a mix of managed and unmanaged C++?

I am going to start implementing some unit tests for a codebase that is a mix of managed and unmanaged C++. Can NUnit hack it with unmanaged code? Is there a better alternative? ...

How to know if a MFC message loop is already running?

Is there any way to know whether a MFC message loop is already running? EDIT: Context: A library (with event handling) needs to know whether its event filtering has to attach to an existing MFC message loop or create its own message loop: in case a main message loop already exists it must not create its own loop because it would be bloc...

C++ Question about default constructor

Hi, I have a question. What does it mean to call a class like this: class Example { public: Example(void); ~Example(void); } int main(void) { Example ex(); // <<<<<< what is it called to call it like this? return(0); } Like it appears that it isn't calling the default constructor in that case. Can someone give a reason why ...

Forcing symbol export with MSVC

I have a application and several plugins in DLL files. The plugins use symbols from the application via a export library. The application links in several static libraries and this is where most of the symbols come from. This works fine as long as the application uses a symbol. If the symbol is not used there, I get linker errors when co...

Efficient way to handle COM related errors (C++)

Efficient way to handle COM related errors in C++. For instance: switch (HRESULT_CODE(hresult)) { case NOERROR: cout << "Object instantiated and " "pointer to interface IS8Simulation " "obtained" << endl; break; //Specifed Class not registered case REGDB_E_CLASSNOTREG: cerr << "Specified Class not registered....

Passing an array as a function parameter in C++

In C++, arrays cannot be passed simply as parameters. Meaning if I create a function like so: void doSomething(char charArray[]) { // if I want the array size int size = sizeof(charArray); // NO GOOD, will always get 4 (as in 4 bytes in the pointer) } I have no way of knowing how big the array is, since I have only a point...

Suppressing Linking Errors in G++ 3.4.6

Don't ask why, but is there any way to suppress a failed linking error? Such as: undefined reference to BLANK This is in GCC 3.4.6 ...

Passing "this" to a function from within a constructor?

Can I pass "this" to a function as a pointer, from within the class constructor, and use it to point at the object's members before the constructor returns? Is it safe to do this, so long as the accessed members are properly initialized before the function call? As an example: #include <iostream> class Stuff { public: static void...

How to get Program Files folder path (not Program Files (x86)) from 32bit WOW process?

I need to get the path to the native (rather than the WOW) program files directory from a 32bit WOW process. When I pass CSIDL_PROGRAM_FILES (or CSIDL_PROGRAM_FILESX86) into SHGetSpecialFolderPath it returns the WOW (Program Files (x86)) folder path. I'd prefer to avoid using an environment variable if possible. I want to compare some...

Why does OpenCV reject cvLoadImage("string.ext"), but accept cvLoadImage(argv[1])?

#include "cv.h" #include "highgui.h" #include <stdio.h> int main(int argc, char* argv[]){ cvNamedWindow("Window1", CV_WINDOW_AUTOSIZE); IplImage* image = 0; ->->image = cvLoadImage(argv[1]);<-<- if(!image) printf("Unable to load image!"); cvShowImage("Window1", image); char c = cvWaitKey(0); cvReleaseImage(&...

Avoiding UAC in vista

Hi, im writing an application that downloads and installs addons for programs which needs to save the data to program files (for the programs in question). Now this works fine on xp and vista with uac disabled however it is failing on normal vista due to the virtual folders. How would one get around this with out needing to request adm...

Why is snprintf faster than ostringstream or is it?

I read somewhere that snprintf is faster than ostringstream. Has anyone has any experiences with it? If yes why is it faster. ...

How to get process info programmatically in C/C++ from a Solaris system?

Is there a C/C++ library, and documentation about how to collect system and process information on Solaris? Although I could parse command-line tools, I'd rather use a library that makes the task easier to do. Thanks Edit: It has been suggested to use the /proc virtual directory to collect information, however its not much better than...

auto_ptr design

In my opinion, a class should provide a well defined abstraction and no private members should be modified without the knowledge of class. But when I checked the "auto_ptr" (or any other smart pointer), this rule is violated. Please see the following code class Foo{ public: Foo(){} }; int main(int argc, char* argv[]) { std::auto_...

When can't an object be converted to a reference?

I want to compile the following line of code from http://code.google.com/p/enhsim: enh::eout << enh::setw(26); gcc gives the following error: error: no match for 'operator<<' in 'enh::eout << enh::setw(26)' But the EnhSimOutput class (of which enh::eout is an instance) does declare: EnhSimOutput& operator<< (setw& p); This probl...

Template class with "typename"

Hi, I have a template class where I want to use objects of that class (along with the parameterized type) inside a map. So far this is the solution that I've been able to arrive at: class IStatMsg; template <typename T> class ITier { public: // Methods ITier(TierType oType) : o_Type(oType){}; virtual ~ITier(){}; typen...

Linking Libraries in Xcode

Hey all, I'm using a powerbook (osx 10.5) and recently downloaded and installed FFTW 3.2 (link text). I've been able to compile and run some simple programs based on the online tutorial using the terminal: g++ main.cpp -lfftw3 -lm however, I can't get the same program to compile in Xcode. I get a linking error, "symbol(s) not found...

XML Schema to C++ Classes

I have to write a C++ Application (using the Qt Framework for the GUI) that can edit data stored in xml files described by a xsd schema file. Is there a tool to convert the xsd schema into C++ Classes? ...