c++

TRACE system function call in c++

how call TRACE in c++?please explain for example with this simple code int x = 1; int y = 16; float z = 32.0; TRACE( "This is a TRACE statement\n" ); TRACE( "The value of x is %d\n", x ); TRACE( "x = %d and y = %d\n", x, y ); TRACE( "x = %d and y = %x and z = %f\n", x, y, z ); ...

Unit Testing .cpp How-To

Alright. I have done screen scrapping program in c++. Now how do i unit test a .cpp? where do i get started? ...

C - PJLIB why not working?

I follow this PJLIB ( https://trac.pjsip.org/repos/wiki/Getting-Started/Autoconf ). But i cant get this up yet, always its giving undefined reference, can anyone please have a look kindly. Stackoverlow source code gets broken please find from here details: http://gist.github.com/5765529 [sun@example mysip]$ gcc myapp.c /tmp/ccEKxwjG....

Function is causing huge memory leak?

I have the following function: void CGlEngineFunctions::GetBezierOpposite( const POINTFLOAT &a,const POINTFLOAT &center, POINTFLOAT &b, float blength ) { POINTFLOAT v; v.x = a.x - center.x; v.y = a.y - center.y; float alength = GetDistance(a,center); if(blength == 0) { blength = alength; } fl...

Program compiles with and without return 0

Possible Duplicate: What should main() return in C/C++? This is a pretty basic question, I guess. I've been programming for a year now but a friend of mine surprised me with a rather stupefying question. Programs that start with 'int main()' on C++ seem to compile perfectly even with 'return 0;' removed and not replaced by a...

How to create a temporary directory in C++?

I'm writing a function in C++ which creates a temporary directory. Such function should be as most portable as possible, e.g. it should work under linux, mac and win32 environments. How do I achieve that? ...

Is it proper to use a default constructor with polymorphism?

I basically have something like this: class CGlToolBase { public: CGlToolBase(void) { } virtual void OnMouseDown(CGlEngine &glEngine, WPARAM wParam, LPARAM lParam); virtual void OnMouseMove(CGlEngine &glEngine, WPARAM wParam, LPARAM lParam); virtual void OnMouseUp(CGlEngine &glEngine, WPARAM wParam, LPARAM lPara...

Passing multiarrays into functions through pointer

Hello, how can I pass multiarray into function through pointer with c++. I can do this with simple arrays void Foo(int *arr) { } int someArr[10]; Foo(someArr); What about 2-dimensions array? ...

How can I simplify interface declarations in C++?

My interface declarations usually (always?) follow the same scheme. Here's an example: class Output { public: virtual ~Output() { } virtual void write( const std::vector<char> &data ) = 0; protected: Output() { } private: Output( const Output &rhs ); // intentionally not implemented void operator=( const Output &o...

Should I create multiple classes?

This applies to several cases in my application: I have 3 or 4 functions that belong together, one is a starting function that creates and frees the required memory structures and calls the other functions as appropriate. The other functions also call themselves repeatedly. Only the starting functions is called from outside, and only on...

Object oriented c++ win32?

I want to create my own class to handle creating windows and the window procedure but I have noticed that the window procedure has to be static! I'm now wondering whether its possible to make the window procedure object oriented? I have read some tutorials on object oriented windows, but they always make the procedure static -.- whats th...

Work with arrays

I'm writing some game at c++. The problem is with arrays. It always shows the 'desk' with points (empty parts). Need comments are in the code: void showDesk(int someArray[][3]) { for(int i = 0; i < 3 ;i++) { for (int j = 0; j < 3; j++) { if(someArray [i][j] == 0) cout << "."; else if ...

Help with this problem?

I'm working on implementing bezier handles into my application. I have points and I need to figure out weather the current direction of the new point is clockwise or counter clockwise. This is because my bezier interpolation algorithm calculates the handles from right to left. Therefore no matter what it interpolates: P1 P1.righthandle ...

C++ - basic function question

Hello! Is there any way to make a function call only once? Suppose I have some class struct A { void MainRoutine(Params) { // Want to call other routine only once } void OtherRoutine(Params) { // Do something that should be done only once and // what depends on the params } }; I want to call Other...

C++ char * to string

Possible Duplicate: how to copy char * into a string and vice-versa I have to pass a value into a method that required a char * MyMethod(char * parameter) { // code } However, the parameter I need to feed it is currently a std::string. How do I convert the std::string to a char *? std::string myStringParameter = //what...

opening an exe from current dir C++

I have the python code... but how do i do it in c++? I don't have much experience with c++. What i want is to make an exe that will be put as autorun in an cd. It has to open the application.ini file in my cd with xulrunner.exe in my cd. As the path will vary in each computer i hav to do something like this. import subprocess import os...

initializer-string for array of array of chars is too long

I am making a patcher for a game but I get the error "initializer-string for array of array of chars is too long" from Mingw. I am trying to make a multidimensional array of chars to contain what functions to patch. I have checked for other questions about this and found one where the asker forgot to add commas to the end of every string...

Fast Arc Cos algorithm?

I have my own, very fast cos function: float sine(float x) { const float B = 4/pi; const float C = -4/(pi*pi); float y = B * x + C * x * abs(x); // const float Q = 0.775; const float P = 0.225; y = P * (y * abs(y) - y) + y; // Q * y + P * y * abs(y) return y; } float cosine(float x) { return sine...

Is it always evil to have a struct with methods?

I've just been browsing and spotted the following... http://stackoverflow.com/questions/54585/when-should-you-use-a-class-vs-a-struct-in-c The consensus there is that, by convention, you should only use struct for POD, no methods, etc. I've always felt that some types were naturally structs rather than classes, yet could still have a ...

C++ static members

Hello! I have the following code: void Foo() { static std::vector<int>(3); // Vector object is constructed every function call // The destructor of the static vector is invoked at // this point (the debugger shows so) // <------------------- int a; } Then somewhere I call Foo several times in a sequence Why doe...