c++

Microsoft C++ Pre-defined Macros

Is there a cl.exe option to dump all the pre-defined Macros ( along with the defined values ). Something like gcc -dM -E - < /dev/null for gcc. ...

C++ calling child virtual member from parent virtual member

I create a parent class that calls it's own virtual member. But this virtual member is overridden by child class. class Parent { public: void doSomething() { doVirtual(); } protected: virtual void doVirtual() {} }; class Child : public Parent { protected: virtual void doVirtual() {} }; Parent *c = new Child(); ...

How to show a number pattern in C++

How can I show the following pattern? 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 ...

C++ iterating through files and directories

I'm working on a C++ program that will automatically backup my work to my FTP server. So far I am able to upload a single file, by specifying a file name using this CString strFilePath = szFile ; int iPos = strFilePath.ReverseFind('\\'); CString strFileName = strFilePath.Right((strFilePath.GetLength()- iPos-1) );...

Replacing native VS 2010 (VC10) tr1 libraries with Boost.TR1

I have been using VS 2005 (VC8) with Boost.TR1 in the std::tr1 namespace by setting the Include Directories of VS to prioritize the boost tr1 headers as described here. Now I am moving over to VS 2010 (VC10) and I seem to be getting compilation errors using the same include method. The Include Directories are set to: [boost-root]\boo...

c++ redefine variable as constant

I have a struct: struct s { UINT_PTR B_ID; }; s d; d.B_ID=0x1; That works fine, but I want d.B_ID to be constant. I tried to use (const) but it didn't work. So after I put a value to d.B_ID, then I want make it a constant. Any ideas? EDIT ok i don't want the whole struct a constant. when i set timer and use the b.B_ID as an i...

Member templates ,Statemement From ISO C++ Standard?

can any one explain this? "Overload resolution and partial ordering are used to select the best conversion function among multiple template conversion functions and or non-template conversion functions." Please explain with a program..... the statement is from ISO C++ Standard 14.5.2 section ,point 8 ...

c++ structures and constructures

ok so i nee help with this constructures struct balls { balls() { SetTimer(hWnd, balls.BALL_ID, 1, null); } int Ex; int Ey; UINT_PTR BALL_ID; }; well when i set the timer im having trouble with balls.BALL_ID. the compiler thinks that balls is structure like balls something. wel...

Postfix -expression evaluation

i am trying to write program for evaluate Postfix-expression code: #include <iostream> #include <cstring> #include <stack> #include <ostream> using namespace std; int main(int argc,char *argv[]){ char *a=argv[1]; int n=strlen(a); stack<int>s; for (int i=0;i<n;i++) { if (a[i]=='+') s.push(s.pop()+s.pop...

what's the implication of void**?

Hi friends~ When I develop in COM, I always see (void**) type conversion as below. QueryInterface(/* [in] */ REFIID riid,/* [out] */ void** ppInterface) What's exact meaning of it? IMHO, it tells the compiler not to enforce type validation, since the type which is pointed by the ppInterface is not known to the client code at compil...

Declare an object in C++ w/o creating it?

Is this possible? For example if i write Car myCar; Then the constructor taking no arguments of Car is called. It results in an error if there is only a constructor taking arguments. In Java I can easily declare an object and create it later using the exact same statement as above. ...

Can gcc/g++ tell me when it ignores my register?

When compiling C/C++ codes using gcc/g++, if it ignores my register, can it tell me? For example, in this code int main() { register int j; int k; for(k = 0; k < 1000; k++) for(j = 0; j < 32000; j++) ; return 0; } j will be used as register, but in this code int main() { register int j; int...

Polymorphic QSharedPointer

I'm trying to use QSharedPointer in my polymorphic stucture, but I couldn't find right syntax to convert pointer of base class to pointer of derived class. struct Switch : State { int a; }; QSharedPointer <State> myState=QSharedPointer <State>(new Switch); QSharedPointer <Switch> mySwitchTest= ??? myState; What should I put in th...

c++ structs and const

ok well i have structure struct balls { balls(UINT_PTR const &val) : BALL_ID(val){} int Ex; int Ey; const UINT_PTR BALL_ID; }; balls ball1(0x1); and i have a switch statement switch(wParam) { case ball1.BALL_ID: if(ball1.Ex<300) { ball1.Ex++; ...

How to Compare Two variable of HANDLE type

i have to variable of HANDLE type . first variable is a process HANDLE (with name hProcess) that have'nt PROCESS_QUERY_INFORMATION access right. second variable is a process HANDLE (with name hwndProcess) too that i opened via OpenProcess function and have PROCESS_QUERY_INFORMATION access right. i sure both process is a one. but when ...

Check COM Inteface still alive?

In COM how does one verify that a pointer to a COM object still has a valid object on the other end? I have an issue where this following bit of code attempts to check if the m_pServer pointer is still alive, however when that application exposing that interface is killed this bit of code crashes the application. Can anybody advice on ...

Memory mapped file class, threads and reference counting

I'm putting together a class I'm going to call a file. The file object simply contains a pointer to a memory mapped file and a link. The constructor takes a file and maps the file onto memory range. In summary it looks a bit like this: class file { public: file(unsigned char* filename) { open(filename); } open(unsig...

GLM + STL: operator == missing

Hi there, I try to use GLM vector classes in STL containers. No big deal as long as I don't try to use <algorithm>. Most algorithms rely on the == operator which is not implemented for GLM classes. Anyone knows an easy way to work around this? Without (re-)implementing STL algorithms :( Kind Regards, Florian GLM is a great math libra...

file syncronization library

Hello I'm looking into C/C++ libraries (Win/Linux) that allow me to synchronize information over network. I want to run multiple instances of my program (on different PC's), and want to synchronize files locally instead of accessing files remotely over the network at a single location. If all instances are to maintain DB consistency it...

Fastest OLEDB read from ORACLE

What would be the fastest way of retrieving data from the Oracle DB via OLEDB? It should be portable (have to work on Postgres and MS SQL), only one column is transfered (ID from some large table). Current performance is 100k rows/sec. Am I expecting too much if I want it to go faster? Clarification: datatable has 23M records Query...