c++

play avi using c++

i want to play an avi file using c++ and direct X with a mfc interface ...

Linux & C++: Easy way to exchange objects between two processes

Hello, I would like to know what is the easiest way (amongst various alternatives) to exchange objects (or some data) between two linux-based systems. It appears socket-programming could be a choice, but I have not done it earlier so I am not sure if it is the best way. Could anyone point me to a reference please? TIA, Sviiya ...

Why don't win32 API functions have overloads and instead use Ex as suffix?

The win32 API has for example two methods StrFormatByteSize and StrFormatByteSizeEx. Even though both the methods symantically do the same thing and the Ex counter part only offers a new parameter to slightly change the behavior then couldn't they have two overloads of the same function? Is it a limitation of c/c++ or what is the possib...

What's the cost of "as" compared to QueryInterface in COM or dynamic_cast in C++?

I'm still trying to map my deep and old knowledge from C/C++ to my somewhat more shallow .Net knowledge. Today the time has come to "as" (and implicitly "is" and cast) in C#. My mental model of "as" is that it's a QueryInterface or dynamic_cast (a dynamic_cast with pointer argument, not reference, that is) for C#. My question is two-fol...

search for multiple indecies with Boost Multi-Index

Hi, how do I limit the search in a boost::multi_index by the result of a previous search? As an example: suppose I have a rectangle class with an internal value like this: class MyRect { public: int width; int height; double value; } and I need a data structure of such object to answ...

Add source code to elf file

Hi, I want to add my C++ source code to the corresponding elf binary file and I'm looking for the best way to do this. (I'm using several versions of my code and not every version should be committed into svn). Can I just append the source code without destroying the elf file using bash's >> operator? Or is objcopy --add-section a way ...

Memory leak/Memory allocation in C++

I have the following function in C++ void func1() { char *p = "Test for memory leak"; } When func1() is called where is the memory for the variable allocated? Whether in the stack or the heap? Should delete p; be called explicitly? ...

copy to cout with hex flag set.

Hi, having something like this: void print_signs() { const char* chars[] = {"abcdefghijklmnopqrstuvwxyz0123456789"}; std::copy(chars,chars + 1,std::ostream_iterator<const char*>(cout)); cout << hex; //trying to change the way output works for next line std::copy(chars,chars + 1,std::ostream_iterator<const char*>(cout)); } is there a w...

Save HICON as a png

I am using IShellItemImageFactory to extract the icon for a file. I was able successfully extract it and show it in a dialog using SendDlgItemMessage(hDlg,IDC_STATIC2, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hicon); see the output: click here The issue is when I am saving this as a file(PNG format) using GDI+ the gradients are not preservi...

C++ 2D dynamic array crash

Hi I'm having some problem with 2D dynamic array. int main() { double **M; int M_dimension; int i; M_dimension = 10; M = new double *[M_dimension]; for (i=0;i<M_dimension;i++) { M[i] = new double[M_dimension]; } M[0][0] = 1.0; ... } Program works but I'd like to initialize 2D array using such a fun...

When can typeid return different type_info instances for same type?

Andrei Alexandrescu writes in Modern C++ Design: The objects returned by typeid have static storage, so you don't have to worry about lifetime issues. Andrei continues: The standard does not guarantee that each invocation of, say, typeid(int) returns a reference to the same type_info object. Even though the standard...

C++ Static member initalization (template fun inside)

Hello all, For static member initialization I use a nested helper struct, which works fine for non templated classes. However, if the enclosing class is parameterized by a template, the nested initialization class is not instantiated, if the helper object is not accessed in the main code. For illustration, a simplified example (In my ca...

What range of values can integer types store in C++

Can unsigned long int hold a ten digits number (1,000,000,000 - 9,999,999,999) on a 32-bit computer. What is the what is the range of unsigned long int , long int, unsigned int, short int, short unsigned int and int? ...

How to draw Windows 7 taskbar like Shaded Buttons

Windows 7 taskbar buttons are drawn on a shaded background. The color shade somehow reacts on where the mouse is over the button. I'd like to use such buttons in my application. How can i do that ? ...

Handling large integer on C/C++ using Visual C++ 2008

How do I do to handles some big positive integers (like 9,999,999,999) on Visual C++ 2008 on a 32-bit PC. Please give an example on declaring, printf, scanf of these big positive integers. Please consider using 9,999,999,999 in your example. ...

Multithreading won't work as expected

Hello, I have a problem with my program. I wanted it to have two threads, one of them listening for connections, and the other one receiving data from them... Unfortunately, it acts strangely. It will ignore my cout and cin usage everywhere in the code, so I can't even debug it. May I ask that someone sheds some light on it? Thank you in...

Plain C callback function pointer as part of iPhone delegate protocol?

Trying to integrate plain C/C++ code into iPhone project as an external static library. So far so good, but now I'm stuck at a point, where I need to register library callbacks. The library should notify my iPhone application, when something happens. Seems like a good place to define a Delegate. ...but the library is expecting C functio...

g++ produces big binaries despite small project

Probably this is a common question. In fact I think I asked it years ago... but I can't remember the answer. The problem is: I have a project that is composed of 6 source files. All of them no more than 200 lines of code. It uses many STL containers, stdlib.h and iostream. Now the executable is around 800kb in size.... I guess I shouldn...

using <map> in C++

hi, I am trying to use "map" container in C++ in the following way: Key is a string and mapping value is an object of type ofstream. If I execute the following code, I get an error that is copied at the end of the message. Could someone please let me know what is going wrong? If it can not be done using 'map' is there some other w...

Compiler error when adding an object to a vector

Why do I get the following compiler error when adding an object to a vector, which its data member is referencing another object? The compiler error: Error 1 error C2582: 'operator =' function is unavailable in 'Product' c:\program files\microsoft visual studio 8\vc\include\xutility 2726 In the program I collect all data before I crea...