c++

C++ "multiple types in one declaration" error

why do I get "multiple types in one declaration" error when compiling c++ program? ...

DeleteFile fails on recently closed file

I have a single threaded program (C++, Win32, NTFS) which first creates a quite long temporary file, closes it, opens for read, reads, closes again and tries to delete using DeleteFile(). Usually it goes smoothly, but sometimes DeleteFile() fails, and GetLastError() returns ERROR_ACCESS_DENIED. File is not read-only for sure. It happen...

What is the fastest sorting algorithm in C++?

If I need to sort 150,000 entries what would be the fastest way for a beginner in C++ to sort that data? All I have learned so far is bubble sort and I know that isn't that efficient. thanks nmr ...

Per-file enabling of scope guards

Hello all. Here's a little problem I've been thinking about for a while now that I have not found a solution for yet. So, to start with, I have this function guard that I use for debugging purpose: class FuncGuard { public: FuncGuard(const TCHAR* funcsig, const TCHAR* funcname, const TCHAR* file, int line); ~FuncGuard(); // ....

How to hook up Boost serialization & iostreams to serialize & gzip an object to string?

Hi all; I've been using the Boost serialization library, which is actually pretty nice, and lets me make simple wrappers to save my serializable objects to strings, like so: template <class T> inline std::string saveString(const T & o) { std::ostringstream oss; boost::archive::binary_oarchive oa(oss); oa << o; return oss.str(); } te...

Copy constructor for a binary tree C++

I have a Tree class with the following definition: class Tree { Tree(); private: TreeNode *rootPtr; } TreeNode represents a node and has data, leftPtr and rightPtr. How do I create a copy of a tree object using a copy constructor? I want to do something like: Tree obj1; //insert nodes Tree obj2(obj1); //without modifying obj1. ...

PInvoke with a "strange" function

I have a .dll written in C++ with a function defined like this: EDK_API int EE_CognitivSetCurrentLevel ( unsigned int userId, EE_CognitivLevel_t level, EE_CognitivAction_t level1Action, EE_CognitivAction_t level2Action, EE_CognitivAction_t level3Action, EE_CognitivAction_t level4Action ) Set the curren...

Making render method virtual?

I'm starting with C++ in more depth while building a simple 2d game engine. In my engine I have (or want to have) an "Abstract" GameEntity class, which carries the methods draw, update, and maybe position (x, y). I will add more stuff while it occurs to me. Classes to inherit from GameEntity would be anything that could be drawn on scre...

Combining function bodies at runtime

This is going to sound super hackish but does anyone know of a way to combine method bodies at runtime in C++? I'm currently on the path of grabbing the address of the functions then memcopy to executable memory but it has the problem of unwanted prolog/epilog. Essentially I've got a few dozen simple operations that take the same argum...

Initialize hashtable c++

I am trying to initialize a hashtable. when i do the stock's operator= overload is called. I am not sure what i need to do in this function? ...

__LP64__ on OS X --> Snow Leopard Equivalent?

When running on Leopard you can do something like: #if __LP64__ #pragma message ("64 bit Leopard issue") #endif What is Snow Leopard and Snow Leopard 64 AND (most importantly) Where would I have found this answer myself and not had to ask? ...

Good IDE/editor for C++ suited to my tastes

First off, I know that this question is asked a lot. I have looked at several threads and I end up being more confused than anything because usually the thread question is vague so the answers are vague as well (ex - What is a good compiler to use? - followed by a list of compilers people recommend depending on who likes what). I would...

How to add picture box in win32 API using visual c++

I have a Window (win32 API) Application in visual c++. I am not using MFC. I have to add a picutre box to my application and Change the image of this picture box periodically. Can any one help me out in achieving the above task? Thanks in advance. ...

was not declared in this scope C++

Why do I get this error in the code below? class ST : public Instruction{ public: ST (string _name, int _value):Instruction(_name,_value){} void execute(int[]& anArr, int aVal){ //not implemented yet cout << "im an st" <<endl; anArr[value] = aVal; } virtual Instruction* Clone(){ return new ST(*this); ...

C++ Wrapper Native Interop Enterprise Scale

I want to know what is the best approach to wrapping a massive library written in C++ to make it accessible in C#. I have done work with interop before, and I love IJW. But I am not sure of how to implement this approach with a huge library. I am wondering if there is any pattern to use, otherwise I just have to write a wrapper around...

Search string parser in C/C++

I work on an open source project focused around Biblical texts. I would like to create a standard string format to build up a search string. I would then need to parse the search string and run the search with the options given. There are a number of different options, from scope of the search, to searching multiple texts, to wildcards, ...

How are you using C++0x today?

This is a question in two parts, the first is the most important and concerns now: Are you following the design and evolution of C++0x? What blogs, newsgroups, committee papers, and other resources do you follow? Even where you're not using any new features, how have they affected your current choices? What new features are you using ...

Accessing tabs on Firefox with a C++ XPCOM extension

What XPCOM interfaces should I use to detect opening, closing and switching of tabs and also get their associated URL from a firefox extension? I have seen instances of code that manage tabs in JS, but how about from C++ ? ...

Logging safely from a worker thread?

In one of my worker threads I want to do some logging. The log messages are channeled to a GUI textarea, which should only be accessed from the main thread. So the problem is: how do I log messages safely from a worker thread? My current solution is to have the logging function check whether we are currently in the main thread. If yes, ...

Error with parsing string and trying to find '\0' character

I'm trying to get one side to send an error message to client, but client isn't able to parse it correctly. My error is >>>>> in my parseString function, it lets index = 0 and therefore I get an out of range for my 'substr' call. Server Side::: #define ERRBUFSIZE 51 string error = "Error - Already Registered: "; erro...