c++

How do I temporarily disable a macro expansion in C/C++?

For some reason I need to temporarily disable some macros in a header file and the #undef MACRONAME will make the code compile but it will undef the existing macro. Is there a way of just disabling it? I should mention that you do not really know the values of the macros and that I'm looking for a cross compiler solution (should work ...

pointers and references question

#ifndef DELETE #define DELETE(var) delete var, var = NULL #endif using namespace std; class Teste { private: Teste *_Z; public: Teste(){ AnyNum = 5; _Z = NULL; } ~Teste(){ if (_Z != NULL) DELETE(_Z); } Teste *Z(){ _Z = new Teste; return _Z; } void Z(Teste *va...

send the enter button input through pipe

how to send return(enter button) character through program in windows c/c++? I want to send an external program "user name" with enter button through pipe but "\n" and "\r" and EOF are not working. consider if pPipe is the pipe stream for sending the data to the remote process stdin... fprintf(pPipe,"username\n"); ...

static method with polymorphism in c++

hi, I have a weird issue using polymorphism. I have a base class that implements a static method. This method must be static for various reasons. The base class also has a pure virtual method run() that gets implemented by all the extended classes. I need to be able to call run() from the static class. The problem, of course, is that th...

Class dependency tool

I'm looking for a (preferably open source) tool that, given a large body of C/C++ code, will generate a visual or maybe XML graph of dependencies between classes (C++) and/or files (C). The idea would be that, if you had to convert the code to another language, you'd like to be able to get the lowest level classes compiling first, and b...

Handling a SAFEARRAY returned from C# server.

Hi, I need to return an array of structure (classes) from a C# library to an unmanaged C++ client. This is the function in the C# library: [ComVisible(true)] [Serializable] public sealed class RetrieverProxy : IRetrieverProxy { public IMyRecord[] RetrieveMyRecords(long[] ids) { IList<IMyRecord> result = new List<IMyReco...

Is C++ Edit and Continue functionality available for anything other than VC++?

Does Eclipse or other IDE's support Edit and Continue for C++? ...

Open source RTP mixer/translator exe or sdk

Hi I need opens source (win 32) sdk or free server with signaling protocol, which implements RTP translator or mixer. e.g receives RTP traffic from one connection and transmits it on the other. Does not have to have conferencing capabilities. Server should implement some kind of protocol which opens, bridges, and closes connections. R...

I want to learn game development. Which language should I use?

I have heard that C++ and Python are two of the most used languages. Which one should I choose? And in Python - version 2 or 3? I am looking at basic game development (like a car racing game, for example) and NOT flash/iphone/browser games. Also I do not want to jump to C#. C++ vs python is what I am considering... also, it wou...

C++: How can a public static member function access private instance member variables?

I'm writing a C++ class to read input from a file into preallocated buffers called "chunks". I want the caller to be able to call a public static Chunk class method called GetNextFilledChunk(), which Grabs a Chunk from an inactive chunk pool Fills the Chunk instance from the input stream using the Chunk's private member variables/func...

Does anyone know where I can find Artificial Intelligence basic problems for practice?

I would prefer if these problems found are more oriented to c++... ...

Correct C++ code file extension? .cc vs .cpp

I have seen C++ code live in both .cc and .cpp files. Which of these (or another!) is the best practice/most modern/best to use? http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml seems to suggest .cc, are there any other opinions or options? I am mainly concerned with programs on Linux systems. =:) ...

String.format()

"%11.2lf" of C++ is equivalent to ? You guys have any resource that shows the equivalent formats for both Java and C++? ...

STL list_iterator code question (STL 4.0.0)

Can anyone explain why the _List_const_iterator would be using _List_node_base and downcast it to _List_node when needed? -- I think there must be some reason behind this. Thanks struct _List_node_base { _List_node_base* _M_next; ///< Self-explanatory _List_node_base* _M_prev; ///< Self-explanatory // ... }; template<...

Wincrypt: Unable to decrypt file which was encrypted in C#. NTE_BAD_DATA at CryptDecrypt

I am trying to decrypt a piece of a file with wincrypt and I cannot seem to make this function decrypt correctly. The bytes are encrypted with the RC2 implementation in C# and I am supplying the same password and IV to both the encryption and decryption process (encrypted in C#, decrypted in c++). All of my functions along the way are ...

Google Earth and Windows application

I have a C++ Windows application continually updating lat, long and altitude. I would like my application to incorporate Google Earth to visually "track it". Any advice or pointing in the right direction would be appreciated. Thanks. ...

combination of a two array ( vector )

Hi, I have v1 and v2 , how should I got a new v like below? v1 = {1,2} v2 = {3,4,5} v = {f(1,3) , f(1,4) , f(1,5) f(2,3) ,f(2,4) ,f(2,5)} I know I could do it using two loops, But If there is more idiomatic way like using STL algorithm? //using two loops for iter1 of v1 for iter2 of v2 v.push_back(f(v1,v2)) EDIT...

Clean code to printf size_t in C++ (or: Nearest equivalent of C99's %z in C++)

I have some C++ code that prints a size_t: size_t a; printf("%lu", a); I'd like this to compile without warnings on both 32- and 64-bit architectures. If this were C99, I could use printf("%z", a);. But AFAICT %z doesn't exist in any standard C++ dialect. So instead, I have to do printf("%lu", (unsigned long) a); which is really...

Compiling C++ programs

Should I use Visual C++ Express to write and compile or should I write in Notepad++ and compile it? I like using Notepad++ because of its clean interface and speedy start-up as compared to Visual which is a considerably heavier program. If I do write in Notepad++ how do I compile it using Visual? ...

How to know the compress rate of a jpeg image?

Is there any method to know the compress rate of a jpeg image? When I am using photoshop, I can set the compress rate when saving a jpeg image, When I am opening a jpeg image, can I read the compress rate of it? I am using freeimage, c++, however I do not find the API. Many thanks! ...