c++

Getting boost::function arity at compile time?

I need to make a decision in a BOOST_PP_IF statement based on the arity (parameter count) of a boost::function object. Is this possible? boost::function_types::function_arity does what I'm looking for, but at runtime; I need it at compile time. ...

In C++, Passing char array to super give erros?

I have this structure: class Base { public: void doACopy(char* strToCopy) { strcpy(str, strToCopy); } private: char str[4]; }; class Derived : public Base { public: void doSomething() { char toCopy[4]; toCopy[0] = 'a'; toCopy[1] = 'b'; toCopy[2] = 'c'; Base::doACopy(toCopy); // is there a...

C++ Reading in words from a text file, word by word or char by char

I've been googling around and reading through my book and trying to write out code to read through a text file and process words out of it, one by one, so i can put them in alphabetical order and keep a count of how many words where used and much a word was used. I can't seem to get my GetNextWord() function to work properly and it's dri...

What 3d engine can be used in 3d editors applications?

but im wander in i need some kind of 3d engine to be used as the core engine for application that in the end will produce me 3d image in good quality for example application like: Xara3d , 3D Home Architect , 3d charts . can it ? ( with combination of Qt ) let me clear my self .. i do not looking for 3d engine this is fine , im going ...

Forward declarations for variables?

I have some C code that I have to port to C++. The code has a structure struct A { ... struct A * myPtr; } And now two global arrays are declared and initialized like this: //Forward declaration of Unit struct A Unit[10]; struct A* ptrUnit[2] = { Unit, Unit+7 }; struct A Unit[10] = { { .., &ptrUnit[0] }, ...

How to properly cast an object?

Hi, I have a code, class foo : public bar { public: foo(){}; ~foo(){}; }; class wu { public: wu(const bar& Bar ) : m_bar(Bar) {}; ~wu(){}; private: bar m_bar; }; int main() { foo tmpFoo; wu tmpWu(tmpFoo); } Now my problem is, the code above will not compile and the error message is "error...

Where are literals stored in statement like this if( var == 'x')?

Say in a statement like this char var; if( var == 'x'); Do we allocate any memory for 'x' at first place? If yes, which is it (stack/data)? Thanks! ...

Is there any concept in c++ like reflector in .Net?

i like to get code from c++ dll ,i know we easily get from .Net dll by reflector. Is there any method available in c++ for this? Thanks In Advance ...

MFC winsock1 and 2

Hi all, I'm deep in trouble with my project. I have to link two radar with my program, but the first has its own library that uses winsock, while in the second I want to use winsock2. How can i do that? At the moment i get many redefinition errors from the includes within winsock.h and winsock2.h. Take into account that the first ra...

Heap corruption during SetClipboardData()

I'm not sure what is the root cause for getting such error(Heap Corruption) from the below code. When i step through the program, the TCHAR value is properly allocated and copied to the clipboard data. However, it crash when it proceed to SetClipboardData(...). Can any guru help to spot the error? Thanks in advance. Error Dialog: ...

C++ Memory Allocation

When using C++, if there is a class: class MyClass { char memory1bye; int memory4bytes; int another4bytes; }; this class uses total of 9 bytes at memory… so if i do something like: MyClass *t1; This will give me a usable address for the Class, but will it allocate the 9 bytes? And will it call default constructor? Or ...

Linux 64 bit porting issue

Hi, I am working on Linux 64 bit porting and we used a lots of long variable in our code. Now on Linux 64 long is 64 bit. We are facing problem in the bits manipulation code. I heard there are options LLP64(long as 32) and ILP64(long as 64). But I don’t know the compiler option for it(g++). I have few more doubts, If I compile with o...

Need to convert char* (pointer) to wchar_t* (pointer)

I am doing some serial port communcation to a computer controlled pump and the createfile function I used to communicate requires the com port name to be parsed as a wchar_t pointer. I am also using QT to create a form and aquire the com port name as a QString. This QString is converted to a char array and pointed to as follows: c...

How to acess COM port of remote system?

I Want to access the COM port present in the remote system from system. Any help would be appreciable. I am using windows XP in both remote as well as local system. ...

Do rvalue references allow dangling references?

Consider the below. #include <string> using std::string; string middle_name () { return "Jaan"; } int main() { string&& danger = middle_name(); // ?! return 0; } This doesn't compute anything, but it compiles without error and demonstrates something that I find confusing: danger is a dangling reference, isn't it? ...

How to correctly write a C++ DLL that will load in debug mode too without crashing

Hi, my problems deals with native C++ DLLs (Visual Studio 2005, if it matters) and how to write them in order to insure that: when the DLL is compiled in release mode, it will be correctly loaded by an EXE compiled in release or debug mode (first priority) when the DLL is compiled in debug mode, it will be correctly loaded by an EXE co...

Is it a good pratice to make constructor explicit

When designing a public API, is it a good practice to make the constructor as explicit? class A { public: //explicit A(int i){} A(int i){} }; void fun(const A& a) {} int main() { // If I use explicit for A constructor, I can prevent this mistake. // (Or shall I call it as feature?) fun(10); } Or shall I allow imp...

How to tell whether Win32 WM_POWERBROADCAST message has interrupted a call stack

How can you tell whether a WM_POWERBROADCAST message has interrupted a call stack? As opposed to happening in isolation with just the message handler call stack? Here's the background: What I see is that during hibernate / resume I get WM_POWERBROADCAST messages. These can seemingly interrupt a (blocked/waiting) callstack for e.g. a WM_...

Implicit Rules in Makefile

hi i want to do a Makefile in linux that will take all the .cpp files in the dir compile them and create one .o file that i can active how i can do it with Implicit Rules thanks mati ...

C++ Returning multidimension array from function

How do I return a multidimensional array hidden in a private field? class Myclass { private: int myarray[5][5]; public: int **get_array(); }; ........ int **get_array() { return grid; } cannot convert 'int ()[5][5]' to 'int*' in return test.cpp /Polky/src line 73 C/C++ Problem ...