c++

Yet another C++ vector memory leak question

Hiya. I'm attempting to make an algorithm that can draw the entities of my isometric game in the correct order. My entities are stored in a vector of pointers. In the drawing function I first create a new vector of the same pointers, and then start with a for-loop that loops the amount of entities that I want to have drawn. Inside that...

How to cope with Install error 1920 about winsxs merge modules in Vista and 7?

Hi all, When I try to install my msi package I get an error only in Vista and 7. "Error 1920. Service ... (...) failed to start. Verify that you have sufficent privileges to start system services" I get this error in Vista or 7 if I build my setup with C++ 9 CRT Winsxs MSM merge module If I use C and C++ 7 runtime libraries it doesn't...

Deal with a lot of if-else , switch

Hi! What is the best way to deal with something like this : if(key==Space) { switch(weapon) { case GUN: p->shotGun(); break; case BOW: p->shotBow(); break; } } else if(key==Enter) { //... } else if(key==Up) { //... } ...

OpenGL: Selecting all dots from the current view area

Im using gluUnProject() to get the screen 2d coordinate in 3d world coordinate. I take 4 positions from each corner of the screen to get the area of visible objects. How to check which points are inside that "rectangle" ?, i have no idea about the terms or anything. The image below shows what that "rectangle" looks like: ...

Custom made win32 drag-drop, can't get change invalid (slashed circle ) cursor.

Hi, I've a quite difficult problem to explain but I will try my best. I've made a custom drag-drop implementation to a win32 GUI based application. Due to limitations of the program I can't use the proper OLE drag-drop mechanism. Its okey, I made my own with mouse key tracking and it works so so. The only problem I can't solve now is t...

3.4.1 Unqualified name lookup

According to C++ standard :- The name lookup rules apply uniformly to all names (including typedef-names (7.1.3), namespace-names (7.3), concept-names (14.9), concept-map-names (14.9.2), and class-names (9.1)) wherever the grammar allows such names in the context discussed by a particular rule. Name lookup rules apply Before Overlo...

C++: What is the default length of an int?

I've been searching for a while but couldn't find a definite answer to this apparently simple question: what is the default length of an int? I know that by default, an int is signed. But is it short or long? According to the "Fundamental data types"table found in the following page, an int is a long int by default (4 bytes). http:...

Error while trying to use class in another class

I'm writing something in C++. I have 2 classes which I want to contain one into the other as in the folowing (these are just the header files): //Timing.h #ifndef _Timing_h #define _Timing_h #include "Agent.h" class Timing{ private: typedef struct Message{ Agent* _agent; //i get here a compilation problem ...

How to skip assembly code when debugging?

Hi, Sometimes when I use the debugger to step through my code, it goes into some assembly code (I guess I've stepped into some system library code). The question is, how can I skip over it and jump to the nearest c++ code of my project? ...

How to get unique pairs of values from a stl set

I have a stl set of integers and I would like to iterate through all unique pairs of integer values, where by uniqueness I consider val1,val2 and val2,val1 to be the same and I should only see that combination once. I have written this in python where I use the index of a list (clusters): for i in range(len(clusters) - 1): for j in...

Check if a class has a method

Possible Duplicate: Possible for C++ template to check for a function's existence? Do you know of any metaprogramming tricks in C++ that allow me to check whether a class has a specific method. I has been thinking about something like this: template <class T, class Enable = void> class A { ... }; // This version of the clas...

visual studio 2008 - Build issues

I am trying to rebuild a project from the clearcase vob and i get the following error code : error PRJ0019 . Any help is very much appreciated .. thankyou ...

3.9.1 Fundamental types

C++ Standard 3.9.1 Fundamental types Objects declared as characters (char) shall be large enough to store any member of the implementation’s basic character set. If a character from this set is stored in a character object, the integral value of that character object is equal to the value of the single character literal...

Operator << overload in c++

#include <iostream> #include <fstream> class obj { public: int i; friend ostream& operator<<(ostream& stream, obj o); } void main() { obj o; ofstream fout("data.txt"); fout<<o; fout.close(); } This is the my code, am getting error. error : ostream : ambiguous symbol. any one can help me. ...

C/C++ API to decode cron-style timings

Does anyone know of a library which will assist in decoding cron style timings, i.e. 30 7 * * 1-5 Which is 7:30am every Monday, Tuesday, Wednesday, Thursday, Friday. M. ...

Generating a set of methods for checking messages' content

Hi, in my unit test framework, for some of the messages ( which are simply POD structures ) I need a method to compare two such messages ( structs ) for equality of all fields. That is if for example I have a message: struct SExampleMessage { int someField; int someField2; char someField3[10]; }; I have a method that take...

C# - convert C++ array of struct w/o tons of new calls?

C++ typedef struct someStruct { int val1, val2; double val3; } someStruct; someStruct a [1000] = { {0, 0, 0.0}, {1, 1, 1.0}, ... }; The only way to initialize such a table in C# I know of is to write something like class SomeStruct { int val1, val2; double val3; public SomeStruct (int val1, int val2, double val3) ...

How to end up with a pointer to 0xCCCCCCCC

Hi, The program I'm working on crashes sometimes trying to read data at the address 0xCCCCCCCC. Google (and StackOverflow) being my friends I saw that it's the MSVC debug code for uninitialized stack variable. To understand where the problem can come from, I tried to reproduce this behavior: problem is I haven't been able to do it. Que...

Our code sucks and I'm powerless to fix it. Help!

Our code sucks. Actually, let me clarify that. Our old code sucks. It's difficult to debug and is full of abstractions that few people understand or even remember. Just yesterday I spent an hour debugging in an area that I've worked for over a year and found myself thinking, "Wow, this is really painful." It's not anyone's fault - I...

Should I protect operations on primitive types with mutexes for being thread-safe in C++?

What is the best approach to achieve thread-safety for rather simple operations? Consider a pair of functions: void setVal(int val) { this->_val = val; } int getVal() { return this->_val; } Since even assignments of primitive types aren't guaranteed to be atomic, should I modify every getter and setter in the program in th...