c++

Question on overloading operator+

Consider the following code: class A { public: A const A const A }; int main() { A a; a = ( a + a ) + 5; // error: binary '+' : no operator found which takes a left-hand operand of type 'const A' } Can anyone explain why the above is returned as an error? "( a + a )" calls "const A& operator+( const A& )" and ...

Variable sized packet structs with vectors

Lately I've been diving into network programming, and I'm having some difficulty constructing a packet with a variable "data" property. Several prior questions have helped tremendously, but I'm still lacking some implementation details. I'm trying to avoid using variable sized arrays, and just use a vector. But I can't get it to be trans...

C++ function-like value pass

Hi, first, sorry for the title but I really don´t know ho to summarize what I want to do. I am trying to write very simple "graphic" console game, just to learn basics of C++ and programming generally. When I have a function, I can pass value, or variable into that function while calling it. But I would like to do the same thing to the p...

Copy Directory - Post Build Event

hi everyone i wanted to ask how do i copy some directory from one place to another (not file by file) in post build event (whats the comman line??). im using vs 2005 (c++ project) thanks, liran ...

C++: building iterator from bits

I have a bitmap and would like to return an iterator of positions of set bits. Right now I just walk the whole bitmap and if bit is set, then I provide next position. I believe this could be done more effectively: for example build statically array for each combination of bits in single byte and return vector of positions. This can't be ...

Inserting into a specific part of a string using iterators? (C++)

string str = "one three"; string::iterator it; string add = "two "; Lets say I want to add: "two " right after the space in "one". the space would be str[3] correct? so: in this case, n = 3; for (it=str.begin(); it < str.end(); it++,i++) { if(i == n) { // insert string add at current position ...

C++ templates hides parent members

Usually, when A is inheriting from B, all the members of A are automatically visible to B's functions, for example class A { protected: int a; }; class B : public A { int getA() {return a;} //no need to use A::a, it is automatically visible }; However when I'm inheriting with templates, this code becomes illegal (at least...

C++ overloading operator comma for variadic arguments

is it possible to construct variadic arguments for function by overloading operator comma of the argument? i want to see an example how to do so.., maybe something like this: template <typename T> class ArgList { public: ArgList(const T& a); ArgList<T>& operator,(const T& a,const T& b); } //declaration void myFunction(ArgList<in...

Direct3D - How do I calculate Roll from View Matrix?

Hey guys, this one's been eating up my entire night, and I'm finally throwing up my hands for some assistance. Basically, it's fairly straightforward to calculate the Pitch and Yaw from the View Matrix right after you do a camera update: D3DXMatrixLookAtLH(&m_View, &sCam.pos, &vLookAt, &sCam.up); pDev->SetTransform(D3DTS_VIEW, &m_View);...

[C++] _dynamic_ array initialization

This is a bit weird, but here goes. I have many hardcoded "tables" that I'm defining as arrays of std::strings or const char *. So for example: const char* resp_desc[] = { "00=Approved", "01=Declined", "03=Incorrect User name", // more values NULL }; In some functions these are passed as the table to lookup the d...

Most efficient way to add data to an instance

I have a class, let's say Person, which is managed by another class/module, let's say PersonPool. I have another module in my application, let's say module M, that wants to associate information with a person, in the most efficient way. I considered the following alternatives: Add a data member to Person, which is accessed by the oth...

OpenGL multiple texture mapping on a cube using GLUT

Have been trying to figure out how to put a different texture on each side of a cube using OpenGL and GLUT. I can get it to be a simple texture but multiple texture won't. I would put up my code but it is ugly and cluttered right now. If this is pretty easy to do please post some code for me to follow. Thanks! ...

Static code Anaylysis tool for C and C++

Possible Duplicate: What open source C++ static analysis tools are available? I am Looking for a static code analysis tool for C and C++ on a Unix platform. Can you please recommend one for me, that you have used your self or know about. ...

How to register all selected entries from a QListView inside a wizardpage?

Hi I've got a QListView inside a wizardpage. There are several entries and multiple selection is active. I want the selected items beeing registered as a field when the 'next' button is clicked. Is it possible? And if how, cause registerfield can't work, connect() nedds an modelindex, iterating over the model-rows doesn't work in w...

Get HModule from inside a DLL.

I need to load some resource from my DLL (i need to load them from the DLL code), for doing that I'm using FindResource. To do that i need the HModule of the DLL. How to find that? (I do not know the name (filename) of the DLL (the user can change it)) ...

How to make google-test classes friends with my classes?

I heard there is a possibility to enable google-test TestCase classes friends to my classes, thus enabling tests to access my private/protected members. How to accomplish that? ...

How to use lock in openMP?

I have two piece of C++ code running on 2 different cores. Both of them wirte to the same file. How to use openMP and make sure there is no crash? ...

Using C Code in C++ Project

Hi .. I want to use this C code in my C++ project : mysql.c : /* Simple C program that connects to MySQL Database server*/ #include <mysql.h> #include <stdio.h> #include <string.h> main() { MYSQL *conn; MYSQL_RES *res; MYSQL_ROW row; char *server = "localhost"; char *user = "root"; char *password = "rebourne"; /* se...

Learning the C++ Standard library - a good idea?

Hello.. I am a beginner programmer in C++, and I still learning the bases, but I have a simple question about The Standard library and STL in C++, I think this is not from The Core of the language, I mean this library just make programming and portability easier, and that mean if I learned and mastered C++ rules, I can build my own, I me...

Appending to boost::filesystem::path

I have a certain boost::filesystem::path in hand and I'd like to append a string (or path) to it. boost::filesystem::path p("c:\\dir"); p.append(".foo"); // should result in p pointing to c:\dir.foo The only overload boost::filesystem::path has of append wants two InputIterators. My solution so far is to do the following: boost::fil...