c++

tips to avoid synchronisation issues in multiplayer and replays using MVC pattern

Hi, just wondering what tips people have for avoiding game synchronisation issues in multiplayer games and replays recorded off of game logic using the model in a model view controller pattern so far im aware that its not a good idea to give non const access to the model anywhere outside of it, but apart from that im a little stuck and...

Developing trading applications

I'm a developer with a .NET background and I'm dying to get into the trading applications realm. What technologies would I have to learn to be able to develop trading applications? I have seen C/C++, any others? What do people use for the GUI? ...

c++ * vs & in function declaration

Possible Duplicate: Difference between pointer variable and reference variable in C++ When should I declare my variables as pointers vs objects passed-by-reference? They compile to the same thing in assembly (at least run-time asymptotically) so when should I use which? void foo(obj* param) void foo(obj& param) ...

Windows std::ifstream::open() problem

I know there's been a handful of questions regarding std::ifstream::open(), but the answers didn't solve my problem. Most of them were specific to Win32, and I'm using SDL, not touching any OS-specific functionality (...that's not wrapped up into SDL). The problem is: std::ifstream::open() doesn't seem to work anymore since I've switche...

Handling COR dump issue with purify

Hi all, I an instrumenting a C++application using IBM purify and I get the issue COR dump and my program aborts although when run from terminal it runs fine. Can anyone tell me what is this COR dump and how to handle with it? Platform: RHEL 64bit Thanx, ...

Most beautiful open source software written in c++

I was told that to be a good developer, you should read a lot of other peoples source code. I think that sounds reasonable. So I ask you, what is the most beautifully written piece of open source software that is written in c++ out there? (Apply any definition of beautiful you like.) ...

destructor problem

this is my addCard function which takes a playingCard as a parameter then hands over the address of its self to an allocated array of pointers to playingCard objects. void cardHand::addCard(playingCard card) { theHand[nElems++] = &card; } // addCard() now when i run my program it runs fine but then crashes when the destructor is c...

How to select an item in a listview which allows only 1 selected item at a time

Hello. I've been trying to select an item on an external listview but it seems to only work with listviews that accept multiple selected items: HANDLE process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, 0xC30); LVITEM lvi; LVITEM* _lvi=(LVITEM*)VirtualAllocEx(process, NULL, size...

In C/C++ can anybody provide some thumb rules for writing small function using inline or macro?

Discussing with people, asking in interviews, or being asked in interviews, I do not know if I know exactly when to write a function as inline or write it as a macro. Apart from compile-time and run-time consideration, is there any suggestion from coding standard point of view. I think this is one of those question where it comes to the...

Are free functions implicitly inlined if defined without a previous declaration in C++?

Is the following free function implicitly inlined in C++, similar to how member functions are implicitly inlined if defined in the class definition? void func() { ... } Do template functions behave the same way? ...

How to generate random variable names in C++ using macros?

I'm creating a macro in C++ that declares a variable and assigns some value to it. Depending on how the macro is used, the second occurrence of the macro can override the value of the first variable. For instance: #define MY_MACRO int my_variable_[random-number-here] = getCurrentTime(); The other motivation to use that is to avoid sel...

what is the basic use of aligned_storage ?

What is the basic usage of std::tr1::aligned_storage ? Can it be used as auto memory for a data type Foo like the one below? struct Foo{...}; std::tr1::aligned_storage<sizeof(Foo) ,std::tr1::alignment_of<Foo>::value >::type buf; Foo* f = new (reinterpret_cast<void*>(&buf)) Foo(); f->~Foo(); If so, what about storing m...

Passing data types from C++ to Java/Java to C++

What data types can be passed between c++ and java/java to c++? Also, are the data types equivalent in terms of size? ...

to insert() or to make new

I'm writing some code that has a lot of substitution. There's a list<char> productions which has a bunch of characters in it. I repeatedly need to replace every character in productions with the rules corresponding to it in a map<char,char*> productionRules. So every character in productions might be replaced by zero or more character...

A function pointer that points to a function that takes an object of a template class with said function pointer as template argument. Possible?

x__x I want to do something like this: typedef long (* fp)(BaseWindow< fp > & wnd, HWND hwnd, long wparam, long lparam); But I get a compile error: error C2065: 'fp' : undeclared identifier Is it possible to implement this somehow? ...

Disable ACPI power button

Hi, is there any simple way to disable processing ACPI power button events (Shutdown) temporarily using the Windows API in Visual C++, so the user isn't able to shut down the computer using the power button? ...

Conditional operator differences between C and C++

I read somewhere that the ?: operator in C is slightly different in C++, that there's some source code that works differently in both languages. Unfortunately, I can't find the text anywhere. Does anyone know what this difference is? ...

is there a functor that derefences a (smart) pointer, upcasts it, and then calls a method on it?

I have class A: public B { ...} vector<A*> v; I want to do for_each(v.begin(), v.end(), mem_fun_deref(B::blah())); (Actually I have: vector<unique_ptr<A>> but it shouldn't matter) I need to upcast and call the member function. ...

Reading input from file prints strange symbols

I'm attempting to solve the project euler problem number 8 with C++, and the problem is to find the greatest product of 5 consecutive numbers in a 1000 digit number. So I'm trying to figure out how to use file io to read the numbers into a char array that I will later convert to integers. The read works except for the last third of the l...

returning C++ stack variable

In this example, why is it ok to return a stack variable? When t() returns, why is it not returning garbage, since the stack pointer has been incremented? #include << string >> #include << vector >> #include << iostream >> using namespace std; class X{ public: X() { cout << "constructor" << endl; } ~X() { cout << "destructor" <<...