c++

what is the official name of C++'s arrow (->) operator?

I think the subject says it all. I always call it the "arrow operator", but I'm sure it has an official name. I quickly skimmed the C++ standard and didn't see it mentioned by name. ...

Call pure virtual function from parent class

Hello, I'm very new to c++, but I think I understand what is going on. The parent class is trying to call the pure virtual member function in the parent class. I thought that by overriding the virtual function in the child class, it would be called instead. What am I doing wrong? Provided for me in parent.h class Parent { public:...

IME - DBCS to virtual key code??

For each key input, WndProc usually receives WM-KEY-DOWN and WM-KEY-UP. However, when IME is in conversion status for Asian languages, WndProc receive WM-IME-COMPOSITION and WM-KEY-UP. no WM-KEY-DOWN.. According to msdn([http://msdn.microsoft.com/en-us/library/dd374133%28VS.85%29.aspx%5D%5B1%5D), WM-IME-COMPOSITION message's wParam is.....

Declaring char[][512]?

I have an C++ SDK that requires a char[][512] as a parameter. I know that this is supposed to be a list of file names and the number of files could vary. For the life of me I cannot figure out how to declare this. I have an array of CStrings and I am trying to copy them over using strcpy_s and then pass them into the SDK. Any idea on how...

Are these placement new macros correct ?

I made a couple macros to make using placement new a bit easier. I was just wondering if there were any obvious cases where these would not work. Thanks. #define CONSTRUCT_INPLACE(TYPE,STORAGE,INIT) ::new((TYPE*)STORAGE) TYPE INIT #define DESTRUCT_INPLACE(TYPE,STORAGE) ((TYPE*)STORAGE)->~TYPE() ...

Running C++ binaries without the runtime redistributable (Server2k3, XPSP3)

Having written a CGI application in Visual Studio 2008 and debigged it locally, I uploaded it to a Windows Server 2003 OS where it promptly failed to run. I am guessing I need to install the wretched Runtime distributable, but after reading this: http://kobyk.wordpress.com/2007/07/20/dynamically-linking-with-msvcrtdll-using-visual-c-20...

Perspective disapeared in Eclipse

I run Fedora 11 x86_64 and I use fedora eclipse. Was compiling code in c++ in my c++ perspective, one of the many I had and than fedora crashed for no reason. No big deal, I just restart my system but when I reopen eclipse for me to continue coding. Eclipse has put me in a weird "resource" perspective. So, I instinctively got to open m...

Maven like build tool for c++ ?

I want a good build tool for c++, just like maven is dedicated to Java is there any build tool dedicated to c++ which does all job that maven does ? Which build tool is normally used for c++ ? I thought of native maven plugin, but doubt of its support, I did not find any c++ repositories for maven. I doubt its used by many c++ develo...

Allocate room for null terminating character when copying strings in C?

Hello, so say I have this: const char* src = "hello"; Calling strlen(src); returns size 5... Now say I do this: char* dest = new char[strlen(src)]; strcpy(dest, src); That doesn't seem like it should work, but when I output everything it looks right. It seems like I'm not allocating space for the null terminator on the end... i...

Expected constructor, destructor, or type conversion before '::' token

I get the below error when compiling my file. //Error PluginDiskstats.cpp:107: error: expected constructor, destructor, or type conversion before '::' token scons: *** [PluginDiskstats.o] Error 1 // destructor ~PluginDiskstats::PluginDiskstats() // line 107 { if (stream != NULL) { fclose(stream); stream = NULL; ...

Problem with method defined in VC++ header file

I have a class in a DLL that's used in many other DLLs and EXEs. It has a couple of methods defined in the include file (i.e. the method body is in the .h file) that's included in the other binaries. One of them is giving me fits: int GetVersion() { return nVersion; }. It is always returning -842150451, but when I run in the debugg...

Profiler for a C++ module in a C# app

I rewrote a number-crunching two pages of code from C# to unmanaged C++ in my project, which with full optimizations gave a 3x speedup. I want to keep optimizing that code, but now my profiler of choice, dotTrace, can't do it, because it only looks at managed code. How do I profile the P/Invoked C++ module when it's running in the C# ap...

How to write an evaluator for a string like "(1+3 * ( 5 / 4)) and get a numeric result.

hi, this is a interview question i am confused about its solution, i am thinking that i need stacks to push and pop these operators and operands, but do i need two stacks, one for operator and one for operands? or would just one stack do?i think we need two stacks but is there any way to solve using one stack? also i am bit confused ho...

Virtual non-method members

Is something similar to this possible? This way it produces an error. class A { public: virtual std::string key; }; class B : public A { public: std::string key; }; int main() { A a; a.key = "Foo"; return 1; } ...

How to identify a new line in C++?

I have to take integer input to an integer array. I have to identify the newline also in input. To be more clear, I have an example. The input I am giving is:- 2 3 4 45 6 78 45 34 34 I want to process the input according to the newline in the input. The programming language is C++ and the compiler is g++. I don't want to store the ...

Rotation Portrait Landscape with 2 XIB

Hello, i have got 2 GUIs and 2 Controllers 1 is called landscapeguicontroller and the second is called highguicontroller. Now generally i call the highguicontroller, and when i rotate my iphone it detects that and then it shows the landscapeguicontroller: Code: landscapeguicontroller *neu =[[landscapeguicontroller alloc] initWithNibNa...

Difference between A* pA = new A; and A* pA = new A();

in C++, what is the exact difference between both following dynamic object creations : A* pA = new A; A* pA = new A(); I did some tests, but it seems that in both cases, the default constructor is called and only it. I'm looking for any difference about performance... Thanks ...

How do you rotate a sprite around its center by caclulating a new x and y position?

I'm using Dark GDK and C++ to create a simple 2d game. I'm rotating an object but it rotates from the top left corner of the sprite. I have the following variables available: PlayerX PlayerY PlayerWidth PlayerHeight RotateAngle (360 > x > 0) Is there an algorithm that will modify the pivot point of the sprite, preferable to the ce...

create a object : A.new or new A?

Hi, Just out of curiosity: Why C++ choose a = new A instead of a = A.new as the way to instantiate an object? Doesn't latter seems more like more object-oriented? ...

How to call a function from binary data

I have some binary data which contains a bunch of functions and want to call one of it. I know the signature of these functions along with the offset relative to the start of the file. Calling convention is the default one: __cdecl. The file was already loaded into a memory page with executing permissions. For example (A, B, C being som...