c++

Install msvcr80d.dll

For reasons beyond my control, an app I am working on deploying needs to use the debug version of the Microsoft Visual C++ 2005 library. I tried to register the msvcr80d.dll with regsvr32.exe and it fails. Is there a work around to get the debug libraries to register? ...

shared_ptr, subscription, destructor

I'm using Boost/shared_ptr pointers throughout my application. When the last reference to an object is released, shared_ptr will delete the object for me. The objects in the application subscribes to events in a central location of the application, similar to the observer/subscriber pattern. In the object destructors, the object will un...

C++ delete - It deletes my objects but I can still access the data?

I have written a simple, working tetris game with each block as an instance of a class singleblock. class SingleBlock { public: SingleBlock(int, int); ~SingleBlock(); int x; int y; SingleBlock *next; }; class MultiBlock { public: MultiBlock(int, int); SingleBlock *c, *d, *e, *f; }; SingleBlock::Si...

Operator= in Boost::Python

If I have something like the following class class Foo { private: int _bar; public: Foo& operator=( const Foo& other ) { _bar = other._bar; return *this; } } Is there an easy way to export that functionality to python using boost::python? The documentation does not list and nice and easy .def( self =...

Compiling and running a C++ program from a Java application

Hey, i need to run a cpp propgram from a java application. I have Visual Studio and Eclipse. I have all of the cpp files and also a .mak file which i'm not sure about how it could help me... any help or direction would be welcome! ...

How to update MFC source code?

After several Visual Studio patches and a service pack or two, my MFC source code no longer matches my MFC binaries. When I trace into MFC, I either see assembly or old source code. How do I get my MFC sources to match my binaries again? ...

Undefined/unspecified ?

Possible Duplicate: Why is i = ++i + 1 unspecified behavior? Consider the following snippet : int i=10; printf("%d %d %d",i,++i,i--); The order in which the arguments to a function are evaluated is unspecified in C/C++.So it lead to unspecified behavior. Am I correct or missing something ? Please Explain. EDIT:Well,some me...

Bind Vs Lambda?

Hi, I have a question about which style is preferred: std::bind Vs lambda in C++0x. I know that they serve -somehow- different purposes but lets take an example of intersecting functionality. Using lambda: uniform_int<> distribution(1, 6); mt19937 engine; // lambda style auto dice = [&]() { return distribution(engine); }; Using bind...

Newb C++ Class Problem

I am trying to get a grasp on pointers and their awesomeness as well as a better C++ understanding. I don't know why this wont compile. Please tell me what is wrong? I'm trying to initialize the pointer when an instance of the class is created. If I try with a normal int it works fine but when I tried to set it up with a pointer i get th...

C++ Automatic Comment Documentation

When I work on C# projects, I can use Microsoft's SandCastle application to generate nice, easy to read and use documentation for my entire code base. I'm curious: Does such an automagic documentation method exist for native C++ applications? ...

Is it good practice to NULL a pointer after deleting it?

I'll start out by saying, use smart pointers and you'll never have to worry about this. What are the problems with the following code? Foo * p = new Foo; // (use p) delete p; p = NULL; This was sparked by an answer and comments to another question. One comment from Neil Butterworth generated a few upvotes: Setting pointers to NUL...

simplest way of recording 8 bit signed mono 16khz sound with alsa (in a way it's compatible with pulse)?

I'm totally lost, does anyone have a very simple example of how to record a sound using ALSA with c++? the only thing i need is the raw samples as signed bytes for feeding them to another part of my program. All the examples i found googling seem to have issues with PulseAudio or don't cover what i need. ...

C++ allocating dynamic memory in a function - newbie question

I'm investigating a memory leak and from what I see, the problem looks like this: int main(){ char *cp = 0; func(cp); //code delete[] cp; } void func(char *cp){ cp = new char[100]; } At the //code comment, I expected cp to point to the allocated memory, but it still is a null pointer meaning I never delete the mem...

Need RPC call example written in C#

Hi All ! I am dealing with WMI connection errors and timeouts and will try to check the RPC stack first. I found the following C code snippet, but do not understand if and how it works and where I may find further informations or even a sample. RPC_STATUS status; unsigned short *StringBinding; RPC_BINDING_HANDLE BindingHandle; status ...

What are the best strategies and examples for teaching C++ memory management to early college students?

So I'm teaching a 2nd semester freshman level C++ course at a university in an upcoming semester. The students have used arrays (though only statically allocated) and have some notion of references and pointers (but probably not much). In general, they have not done a whole lot of dealing with dynamic memory allocation and management. I...

Does msvcrt.dll use a linear congruential generator for its rand() function?

I am trying to predict the output of a program that uses msvcrt's rand() function for generating the face of three dice. I believe the code is something like: dice[0] = rand() % 6 + 1; dice[1] = rand() % 6 + 1; dice[2] = rand() % 6 + 1;, and I was wondering if I could use a prediction program for linear congruential generators to predict...

Any disadvantage if only using cpp files without separate header files?

I have found some threads that explain why C++ separates .cpp and .h files (e.g. here). I'd be interested to know if it causes any problem if I don't separate them. I don't want to share the object files, so what's the benefit of the separation on a small project? If it just slows down the compilation time, it's not a big deal in my opin...

Give me an example of Unicode XML parsing using PugiXML

I have tried to find some code for this job in the tutorials and by googling, no luck. If someone has used PugiXml, could you please help me out ? My main trouble is Unicode, otherwise the library is very easy to use. Thanks in advance. ...

How to map XML schemas to C/C++ code?

What the best way to map XML schemas to C/C++? Here is an example: ------ C/C++ ----- struct zone { char *var_name; float var_value; }; ------ XML ----- <xs:element name="zone"> <xs:complexType> <xs:sequence> <xs:element name="Var_name" type="xs:string"/> <xs:element name=...

RAII for singleton

I have a singleton class, whose instance get initialized at global scope within the class's CPP file: Singleton* Singleton::uniqueInstance = new Singleton(); Its header file looks like: class Singleton { public: static Singleton& getInstance() { return *uniqueInstance; } static bool destroyInstance() { delete uniqueInstance; ...