c++

What is the Best Practice for Combating the Console Closing Issue?

After compiling console programs the console window closes immediately after running. What is the best practice for keeping it open? I've searched google loads, I'm used to codeblocks where you don't have to worry about it, but, I want to mess around with Visual Studio a bit and with VS, my console closes. All over the interwebz there ar...

C++ and Qt - Problem with 2D graphics

Mission: Draw two lines with different color on one graph with automatic cliping, by adding points bit by bit. So, what am I doing. Create class GraphWidget, inherited from QGraphicsView. Create member of QGraphicsScene. Create 2 QPainterPath instances, and add them to graphicsScene. Then, I eventually call graphWidget.Redraw(), where ...

Run Code Before Every Function Call for a Class in C++

I would like to run some code (perhaps a function) right before every function call for a class and all functions of the classes that inherit from that class. I'd like to do this without actually editing every function, Is such a thing even possible? I would settle for having a function called as the first instruction of every functi...

function passed as template argument

I'm looking for the rules involving passing C++ templates functions as arguments. This is supported by C++ as shown by an example here: #include <iostream> void add1(int &v) { v+=1; } void add2(int &v) { v+=2; } template <void (*T)(int &)> void doOperation() { int temp=0; T(temp); std::cout << "Result is " << temp << std::e...

Linker problem on VS2005 with VC++

Here's the scenario: Platform: VS2005 and language is VC++ Situation: There's just 1 assembly CMPW32. It has 2 projects: 1 is a DLL project called CMPW32 and the 2nd one is an .exe project called Driver They both share the same Debug folder under the main assembly folder. I have been able to successfully export a few functions from t...

How do I return a pointer to a user-defined class object using SWIG

I have the following code wrapped by swig: int cluster::myController(controller*& _controller) { _controller = my_controller; return 0; } controller has a private constructor. What's the correct incantation to make something like this not throw an exception? public static void main(String argv[]) { controller c = null; ...

Run .exe outside IDE but use break points inside IDE

Using VS .NET 2003. Would like to run the .exe from outside the IDE (i.e. command prompt or double clicking .exe icon in windows) However, still want break points to hit in the IDE. How do I set this up? (Running from outside IDE but IDE seeing it as run from "Debug" -> "Start") Thanks. ...

Timer Interrupt Service Routine on a host computer running at a rate of 10 microseconds or faster

I am trying to run the following pseudocode at a rate of 10 microseconds or faster on a host computer (512 mb RAM, Intel 2.5 GHz Pentium 4 processor, etc.) running on a Windows XP operating system: int main(void) { while(1){}; } Interrupt service routine: every 10 microseconds, printf("Hello World"); I'm aware that there are MFC ...

Auto updated header comments in C++

Hi everyone! This is one of the headers I found in WxWidgets and I like it. I wonder if there is a way to insert in all my source files a header like this and maintain it automatically updated? It includes two properties of SVN which I am aware of. ///////////////////////////////////////////////////////////////////////////// // Name: ...

CallNamedPipe & NamedPipeServerStream, access denied?

I'm trying to do some IPC between a managed and unmanaged process. I've settled on named pipes. I'm spinning up a thread in managed code, using NamedPipeServerStream: using (NamedPipeServerStream stream = new NamedPipeServerStream("MyPipe", PipeDirection.In)) { while (true) { stream.WaitForConnection(); stream.Read(buffer,...

Bad pointer or link issue when creating wstring from vc6 dll

I got a DLL generated on VC6 and using wstring, and I'm trying to use it in a VC9 project. In this DLL there is a higher level class manipulating wstring, called UtfString. I got everything imported correctly in my project, but when I call: std::wstring test; UtfString uTest(test); it won't link, even if the function prototype is in...

Is it possible to instruct MSVC to use release version of Boost when compiling Debug project?

I have built Boost in Release configuration and have staged it into one folder. Now when I add Boost libraries into project and try to build it in Debug configuration - linker fails because there are no Debug versions libraries. Is there a way to make MSVC 9.0 use Release version of libraries when building Debug configuration? Of cours...

Mapping a branching tile path

I'm working on a game (and have asked a couple questions on it already), and now I have another question to ask of you guys. The level format in this game is set up as a tilemap of Uint16's (I'm using SDL) which are indices into an array of tilemapData structs. One of the bits of the tilemapData struct is the isConductive bit/boolean. ...

Appropriate way to add "media" files to c/c++ project in netbeans IDE

I have a a c/c++ project in netbeans 6.7 . The project requires a .dll file be located in the same directory as the .exe file, and it also needs a "media" directory (which contains a bunch of png files) within the same directory. I'd like to set it up so netbeans will automatically do this for me. How do I go about doing this? ...

Can I cast std::vector<Animal*> to std::vector<Dog*> without looking at each element?

I have a base class with several classes extending it. I have some generic library utilities that creates a vector containing pointers to the base class so that any of the subclasses will work. How can I cast all of the elements of the vector to a specific child class? // A method is called that assumes that a vector containing // Dogs ...

C++ - when should I use a pointer member in a class

One of the thing that has been confusing for me while learning C++ (and Direct3D, but that some time ago) is when you should use a pointer member in a class. For example, I can use a non-pointer declaration: private: SomeClass instance_; Or I could use a pointer declaration private: Someclass * instance_ And then use new() o...

Detail Grid in MFC

I want a detail grid kind of control in MFC, where on expanding each row of the grid an embedded dialog would appear for it (not a popup but inside the same parent control, inside which I can show other controls). Can you please point me if there is any such existing library providing this kind of a control? Or else how to go about impl...

gcc linker errors when using boost to_lower & trim

Hi I'm trying to use the boost library in my code but get the following linker errors under Sparc Solaris platform. The problem code can essentially be summarised to: #include <boost/algorithm/string.hpp> std::string xparam; ... xparam = boost::to_lower(xparam); The linker error is: LdapClient.cc:349: no match for `std::string& ...

How to do type conversion for the following Scenario??

Hi I am using TCHAR buffer[MAX_SIZE]; after some set of steps i am gettig the relative path of folder say for ex: c:\Microsoft.NET\Framework\v1.0.037\ Since the above path is in buffer of type TCHAR and i am trying to concatenate"RegAsm.exe" After Appending i need to convert the path to the LPCTSTR since i need to pass it to Crea...

Implement IDropTarget

I would like to drag and drop files from windows explorer onto my application which is being built in Codegear RAD studio 2009. Then I would like to be able to access data from the object I am dragging and dropping. I believe I have to implement IDropTarget. Can someone please provide an example of how I might implement IDropTarget to ac...