c++

C# objects and C++ objects, the difference

When creating an object instance as such in C# Myclass mc = new Myclass(); This mc is now a reference to a Myclass object created in memory. It's like a 'pointer' to that memory. Is it the same or comparable to doing this in (Managed or Unmanaged) C++: MyCppClass *mcCppClass = new MyCppClass(); Because this actually creates a po...

Does a destructor always get called for a delete operator, even when it is overloaded?

I'm porting a bit of an old code from C to C++. The old code uses object-like semantics, and at one point separates object destruction from freeing the now-unused memory, with stuff happening in between: Object_Destructor(Object *me) { free(me->member1), free(me->member2) } ObjectManager_FreeObject(ObjectManager *me, Object *obj) { fre...

How to print ACE_thread_t using printf()

ACE_OS::thr_self() returns ACE_thread_t. ACE logger has a switch "\t" to print it. How can I do it if I want to print thread id by using printf()? ...

How is a union different from a struct? Do other languages have similar constructs?

Possible Duplicate: Difference between a Structure and a Union in C I see this code for a union in C: union time { long simpleDate; double perciseDate; } mytime; What is the difference between a union and a structure in C? Where would you use a union, what are its benefits? Is there a similar construct...

Why exactly do I need an explicit upcast when implementing QueryInterface() in an object with multiple interfaces()

Assume I have a class implementing two or more COM interfaces: class CMyClass : public IInterface1, public IInterface2 { }; Almost every document I saw suggests that when I implement QueryInterface() for IUnknown I explicitly upcast this pointer to one of the interfaces: if( iid == __uuidof( IUnknown ) ) { *ppv = static_cast<IIn...

std::vector::reserve performance penalty

inline void add(const DataStruct& rhs) { using namespace boost::assign; vec.reserve(vec.size() + 3); vec += rhs.a, rhs.b, rhs.c; } The above function was executed for about 17000 times and it performed (as far as I can see. There was some transformation involved) about 2 magnitudes worse with the call to vector::reserve. I ...

Vista/Win7 Listview "View Slider"

In Vista and Windows 7 almost any time the system uses a standard Listview (ie: Explorer Windows) it's accompanied by a little split button that shows a slider when the split is clicked that allows you to switch between the different views available for that listview (Tile, Details, List, etc.) as well as sliding smoothly between icon si...

Are there C/C++ compilers that do not require standard library includes?

All applicants to our company must pass a simple quiz using C as part of early screening process. It consists of a C source file that must be modified to provide the desired functionality. We clearly state that we will attempt to compile the file as-is, with no changes. Almost all applicants user "strlen" but half of them do not inc...

visual studio plugins for C++ environment

hi there 1) I'm new into C/C++ development using Visual Studio 2008 and after some searches here i didn't find any posts related to C/C++ Visual Studio plugins besides Visual Assist X?(there are a lot of posts related to C# and asp VS environments). 2) The right approach about learning how to use those tools is to learn/try them one ...

RegisterClassObjects() Doesn't Find Classes To Register

I'm in the process of converting an application from Visual Studio C++ 6.0 to Visual Studio 2008 and am running into problems with ATL. I've been having a whole host of issues, but this is the first call that differs in return values between the two different compilers. The following line, when compiled with VC++ 6.0, returns S-OK. Wh...

Is there a tool for Visual Studio to track (or breakpoint) variable value?

Is there is a tool or a setting in the debugger to stop on the break point or if variable is set to a particular value? I mean if I know that value will be set to "HELLO" then the debugger will stop or do the same if it reached some break point in the loop? Any advise would be helpful! ...

Displaying an EMF file

Hey guys! Got a quick question about Windows EMF/EMF+ files. Reading the documentation, I realize that an EMF/EMF+ file is just a bunch of GDI/GDI+ commands. So what's the supported way for reading in an EMF/EMF+ file and then displaying it in either MFC or WinForms? Thanks, Alex ...

Is there a C or C++ embeddable library for reading email through pop ?

I'm looking for a not too big C or C++ library that would allow to read email through pop on Windows. The smallest the better. It would be better if it could support SSL. ...

How to programmatically tell if two variables are on the same stack? (in Windows)

I'm in a thread. I have an address. Is that address from a variable on the same stack that I'm using? static int *address; void A() { int x; atomic::CAS(address, 0, &x); // ie address = &x // ... } void B() { int y; int * addr = atomic::read(address); // ie addr = address if (addr && on_same_stack(&y, addr)) ...

String (C++) in XCode

Does anyone know why in XCode, when you do something simple like string str; cout << "input string"; getline(cin, str); cout << str; you would get malloc: *** error for object 01x100000240: pointer being freed was not allocated error? thanks. ...

C++ linker - Lack of duplicate symbols

Why does the following code not give me a duplicate symbol linker error for Impl? I ran across this problem in some code I inherited and I'm recreating a shorter version here for simplicity. I have two classes, Foo and Bar, that each define a different version of the same struct (Impl) in each of their .cpp files. So Foo.cpp and Bar.c...

C++ Access to command line arguments outside main?

I have a couple command line apps that both end up calling into com objects. Rather than adding new interface to these com objects, can they access the parameters passed from the command line? Edit: Sort of how I can call GetModuleFileName to get the file name. Im wondering if there is an equivalent method to get the args. ...

Determining value based on adjacent cells in matrix

Input: a maze represented by an arbitrarily sized matrix of bools. (Out of bounds counts as 0) 00100 00100 01110 11111 01110 00100 Output: a nice looking representation of the maze (neighbourhood gets mapped to a wchar_t): ┌─┐ │1│ ┌┘1└┐ ┌┘111└┐ |11111| └┐111┌┘ └┐1┌┘ └─┘ Edit: Basically each 0 gets mapped to a 4 bit ...

Making a program timer-based rather than frame-rate dependent?

I have a game engine to work on as part of a class. Currently, its rendering is frame-rate dependent and one requirement is to move to a timer-based dependency. I am not sure how to determine where it is relying on frame-rates. I'm not sure what to look for. I realize I'm going to need to somehow incorporate a timer (GetTickCount?) to...

Function returning variable by refrence???

In C++, function() = 10; Works if function returns a variable by reference, right? Would someone please elaborate on this in detail? ...