c++

How can a script retain its values through different script loading in Lua?

My current problem is that I have several enemies share the same A.I. script, and one other object that does something different. The function in the script is called AILogic. I want these enemies to move independently, but this is proving to be an issue. Here is what I've tried. 1) Calling dofile in the enemy's constructor, and then ca...

Implementing pImpl with minimal amount of code

What kind of tricks can be used to minimize the workload of implementing pImpl classes? Header: class Foo { struct Impl; boost::scoped_ptr<Impl> self; public: Foo(int arg); ~Foo(); // Public member functions go here }; Implementation: struct Foo::Impl { Impl(int arg): something(arg) {} // All data members...

Best way to programatically check for existence of header file?

Is it just to test compile a simple program, with that header file #included in it? To better understand the compilation process I'm writing my own "configure", which tests for the existence of a few header and library files. ...

How to create a window based on only the size of the screen not including the windows border with C++/Windows?

When creating a window using CreateWindow(...), which requires the window width and height, I have to enter the values 656 and 516, instead of 640 and 480, so as to account for the windows border. I'm wondering if there is a way to create a window based only on the portion of the window not including the border, especially considering t...

Auto resizing of contents of QDockWidget

I've created a dock widget which contains a QTreeView. The size of the tree view remains static when the dock is resized. How can I get it to change it's size automatically to fill the dock area? I've created the dock widget using the designer and use multiple inheritance to include it in the main app. Inherited class: class TreePaneW...

At what exact moment is a local variable allocated storage?

Suppose we have the following: void print() { int a; // declaration a = 9; cout << a << endl; } int main () { print(); } Is the storage for variable a allocated at the moment function print is called in main or is it when execution reaches the declaration inside the function? ...

Variadic Macros : how to solve "too many actual parameters for macro.."

Ive been working on getting some of my code originally built on the mac to run under Visual Studio 2008 Express and have run into a weird problem with the variadic macros i use for my assert code : The macro is defined as : #define SH_ASSERT( assertID, exp, description, ... ) shAssertBasic( int(exp), assertID, description, __LINE__, _...

Why doesn't my function give the desired result?

One Class object, GeneSeqs, creates an array of objects, Sequence, of class type Sequence. The GeneSeqs then cycles through each Sequence and calls certain functions that modify Sequence::aaSeq of type string. In the end the aaSeq strings are == the GeneSeqs::GeneSeqs(char * originalSeq,Limits * originalLimits, int length){ codingSe...

typedef struct problem

hi, I'm new in c++, how to made code below work (compile without a syntax error)? typedef struct _PersonA{ char name[128]; LPPersonB rel; }PersonA, *LPPersonA; typedef struct _PersonB{ char name[128]; LPPersonA rel; }PersonB, *LPPersonB; Please, don't ask me why I need to do it like this, because it is just an exampl...

Printing messages to console from C++ DLL

Hi, I have an application which uses C# for front end and C++ DLL for the logic part. I would want to print error messages on console screen from my C++ DLL even when the C# GUI is present. Please let me know how to do this. Thanks, Rakesh. ...

how to remove what setpixel put on the window?? (c++)

im using SetPixel to make stuff on my window which is the easyest because i only want to set one pixel at a time. SetPixel is great but i need to remove the color every time i update it, i could overwrite the color by black but.. it's a really big waste of time is there some way i can over write all of the colors to black? (i would like ...

P/Invoke a purely C++ library?

I am just wondering if it is possible to P/Invoke a pure C++ library, or does it have to be wrapped in C? ...

Flex GUI for C++ application, how to do it?

What is the method to create a flex GUI for a c++ API and connect them? what is the procedure to do that? If any one can give me a helloworld example or some example it would be very easy to understand!! Thanks in advance. ...

Template member function virtual?

I heard, templated member functions of a class can't be virtual. Is it true? BTW, if they can be, then please give an example of such a scenario when I would need such function? ...

how to write and read a file at same time

What I am trying to do here is to find right place in a file and start writing. I gave a shot with fstream and got an error saying: variable ‘std::fstream myfile’ has initializer but incomplete type the code I declare it is: fstream myfile(FILENAME, ios::in|ios::out); any comments? Or there is better way to handle this? thanks ...

Input from console window in game

when you want to input in console window and you hold a key down for a moment, the output is displayed but after a bit of some lag. for example, in any type of common text editors you would see the same result. is there anyway to get a direct input for console games? I'm currently using _getch() to read the keyboard input and _kbhit to ...

Static source code analysis with LLVM

I recently discover the LLVM (low level virtual machine) project, and from what I have heard It can be used to performed static analysis on a source code. I would like to know if it is possible to extract the different function call through function pointer (find the caller function and the callee function) in a program. I could find th...

C socket API is thread safe?

I'm using both Linux and Win32 socket APIs. In my program, multiple threads share a socket handle. In particular, multiple threads call send with the shared socket handle (i.e., the same port). In this case, do I have to put a lock for thread safety? I was unable to find the answer. I may do a test, but want to hear your experiences. ED...

Add a tooltip to a CStatic Ctrl

Is it possible to add a tooltip to a CStatic Ctrl in Visual C++6? How? ...

Calling a method with this pointer from an inherited class becomes const.

class A { } class B : public A { doSomething { C * c = new C(this); } } class C { C(A* copy); } In the following example I get the following error: error: no matching function for call to `C::C(B* const)' I wan't to get the A pointer in the this call but for some reason I can't get this through. Probably so...