c++

Mixing Static and dynamic libraries

I am working with three different libraries, a Core (can be compiled as static or DLL), Graphics (can be compiled as static or DLL - Dealing with Ogre), Physics (can be compiled as static only due to licensing - Havok). A project then uses a combination of the libraries depending on the needs. The Physics portion is dependent on some fun...

Where should I go after learning C++?

I'm in high school and taking a class where basically we design our own course and choose what we learn. I've chosen to learn about C++ and game programming. I'd like to learn as much about using C++ with OpenGL or DirectX or some other API as I can. After I finish learning C++ where should I go? Can you recommend a book on game prog...

64 bit floats compiled with 32 bit compiler on 64 bit OS.

I hope this has not been covered before, but if i compile a 32 bit program in c++ that uses 64 bit floating point numbers (double), and run it on a 64 bit OS, will it still take as many clock cycles to move the 64 bit float to the cpu and back to ram as it would on a 32bit OS because its compiled for 32 bit. Or would it take less clock c...

How to copy structure in c/c++?

DECLARE_PTR(VIDEOINFOHEADER, pvi, pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER))); ZeroMemory(pvi, sizeof(VIDEOINFOHEADER)); //initialize Vih VIDEOINFOHEADER Vih; Vih.aaa = xxx; Vih.bbb = yyy; ... //now how to copy the value of Vih to pvi? Anyone knows? ...

Progress bar embedded in listview

Hello, Does anyone know how I can add a progress bar to a listview cell using "pure" api. The only examples I've found are either in c# or outdated mfc ...

How do I get resize handles in QT?

Is there a way to get a resize effect between two widgets? Like say I have two QTextEdit boxes next to eachother, I want to get a handle between them so I can move it back and forth. Sort of in the same way that the textarea I'm writing in now has a handle at the bottom for making it larger. I'm using QT Creator and I can't seem to figu...

Detect double free in C++ code.

Hi, I have a code, class foo { public: foo(){}; ~foo(){}; }; class bar { public: bar(){}; ~bar(){}; foo& Foo() { return m_foo; } private: foo m_foo; }; int main() { bar *obj = new bar; if( /* true condition here */ ) { foo lcFoo; lcFoo = obj->Foo()...

C/C++ Array initializer problem...

Can someone explain why I can do: int x[4] = { 0, 1, 2, 3 }; int *p = x; But cannot do: int x[2][2] = { 0, 1, 2, 3 }; int **p = x; Is there a way to be able to assign to **p the x[][]? TIA ...

How to handle audio-card buffer

Im trying to do a screen-flashing application that flashes the screen depending on the audio(like an audio visualizer, but instead of a visualization like bars or something like that, just flash the screen). I already made the music player and know how to make the widget get full screen and change color(which will flash), but I dont kno...

How to convince people that a single class with 11975 lines of code is bad? (isn't it?)

I have a dejavu feeling when reading [What to do about a 11000 lines C++ source file?] post, but I don't think I can start taking action on my own since I do not have the authority to take action. So I think the first step is to convince people in the organization that big lump of code is bad. I have a similar situation where there is a...

How To Make a clone method using shared_ptr and inheriting from enable_shared_from_this

I have seen that a useful way to write a clone method that returns a boost::shared_ptr is to do class A { public: shared_ptr<A> Clone() const { return(shared_ptr<A>(CloneImpl())); } protected: virtual A* CloneImpl() const { return(new A(*this)); } }; class B : public A { public: shared_ptr<B> Clone() const { ...

Event when cursor changes position wxWidgets Text Box?

In wxWidgets, how can I detect when the cursor position changed in a wxTextCtrl? I looked at the manual and couldn't find any event relating to it, but maybe there is another way I've missed. ...

Object-oriented programming

I am developing a project in C++. I realised that my program is not OO. I have a main.cpp, and several headers for different purposes. Each header is basically a collection of related functions with some global variables to retain data. I also have a windowing.h for managing windows. This contains the winMain() and winProc(). It calls t...

c++ having strange problem

I have a function that creates and insert some numbers in a vector. if(Enemy2.dEnemy==true) { pt.y=4; pt.x=90; pt2.y=4; pt2.x=125; for(int i=0; i<6; i++) { Enemy2.vS1Enemy.push_back(pt); Enemy2.vS2Enemy.push_back(pt2); y-=70; pt.y=y; ...

synchronizing between send/recv in sockets

I have a server thats sending out data records as strings of varying length(for eg, 79,80,81,82) I want to be able to receive exactly one record at a time.I've delimited records with a (r) but because I dont know howmany bytes I have to receive, It sometimes merges records and makes it difficult for me to process. ...

[edit] recursive template?

Rephrased Question I found that my original question wasn't clear enough and the repliers misunderstood my problem. So let me try to clarify: Let's say I have two classes: struct C { void(*m_func)(C*); }; struct D { std::function<void(D*)> m_func; }; Now I want to make a generic version of the two, so I do something like this: temp...

Referencing a pointer in a C++ member function.

Hi, I'm writing a member function that uses a member variable pointer as an iterator. However I want to reference the pointer within the function purely for readability's sake. Like so: /* getNext will return a pos object each time it is called for each node * in the tree. If all nodes have been returned it will return a Pos * objec...

C++: Copying hashmap contents to pointer list

I have a hashmap which contains items of struct Foo (not pointers). Now, I want to have pointers of those items in a list. How can I do this? I have tried to iterate the hashmap and insert the &*iter's to the list but the pointers get invalidated as soon as they are out of scope. I should be able to do this without dynamic allocation,...

c++ " undefined reference to 'Foo::Foo(std::string)' "

I'm not too familiar with c++ and how instantiating objects work, so this is probably a very simple thing to solve. When I compile with g++ I get the error " undefined reference to 'Foo::Foo(std::string)' ". I want to create an instance of the class Foo that has a string parameter in its constructor. Here is the code: Foo.h #include...

socket max number of sends?

Is there a maximum on the number of sends on a socket? My sends work upto about 480 sends after which it starts returning -1 I'm using visual studio 2008 vc++ and socket programming using ACE. ...