c++

C++ Win32 Unhandled Exception Handler

currently I used SetUnhandledExceptionFilter() to provide callback to get information when an unhandled exception was occurred, that callback will provides me with EXCEPTION_RECORD which provides ExceptionAddress. [1]what is actually ExceptionAddress is? does it the address of function / code that gives exception, or the memory address ...

Function in c++ for finding if a word is prefix

Let say i have some words AB, AAB, AA. AB is not a prefix to AAB but AA is a prefix to AAB because if i just add B at the end of AA it will become AAB, which is not possible with AB. So, is there any function in c++ (STL) so that i can determine of two words if one is prefix to the another ? Thanks. ...

How to create static method that evaluates local static variable once?

I have a class with static method which has a local static variable. I want that variable to be computed/evaluated once (the 1st time I call the function) and for any subsequent invocation, it is not evaluated anymore. How to do that? Here's my class: template< typename T1 = int, unsigned N1 = 1, typename T2 = int, unsigned N2 =...

Creating a C# DLL and using it from unmanaged C++

I have a native (unmanaged) C++ application (using wxWidgets for what it's worth). I'm considering a separate tool application to be written in C# which would contain winform-based dialogs. putting some of those dialogs in a separate DLL would be useful as I'd hope to be able to use them from my C++ app. But I have no idea how much mess...

webdav implementation in c

Hello Everyone, I would like to know do we have any webdav protocol implementation in c or c++. Thank You in advance.. ...

ANTLR - accessing token values in c/c++

I am trying to parse integers and to access their value in antlr 3.2. I already found out how to do this in Java: //token definition INT : '0'..'9'+; //rule to access token value: start : val=INT {Integer x = Integer.valueOf( $val.text ).intValue(); } ; ... but I couldn't find a solution for this in C/C++. Does someone...

Why the function from immediate parent is called and not from grandparent class. Is this called function overriding?

class A { public: void test () { cout<<"In A"; } }; class B :public A { public: void test () { cout<<"In B"; } }; class C : public B { public: int c; }; int main() { C c; c.test(); } The result is: In B... ...

Why does this fail without static_cast?

Compiling f works, but compiling g fails with an error. Why does this happen? class A { public: A() {} }; class B : public A { public: B() {} }; void f() { A* a = new A(); B* b = static_cast<B*>(a); } void g() { A* a = new A(); B* b = a; } ...

Boost::binary<>

Hi, Is there anything in boost libraries like binary? For example I would like to write: binary<10101> a; I'm ashamed to admit that I've tried to find it (Google, Boost) but no results. They're mention something about binary_int<> but I couldn't find neither if it is available nor what header file shall I include; Thanks for help. ...

Debugging metaprograms

Hi, Is there any way to check step by step what's going on in let's say template? I mean how it is instantiated step by step and so on? In book I've mentioned here , I found (2 minutes ago) quite interesting example of how binary could be implemented as a metafunction. template <unsigned long N> struct binary { static uns...

C++ Implicit Conversion Operators

I'm trying to find a nice inheritance solution in C++. I have a Rectangle class and a Square class. The Square class can't publicly inherit from Rectangle, because it cannot completely fulfill the rectangle's requirements. For example, a Rectangle can have it's width and height each set separately, and this of course is impossible with ...

operator new and new operator, which can't be overloaded?

It seems both can be overloaded, but somebody said not..... What's the case? ...

Cannot cout data

Hi, Guys, reffering to last post I'm trying to output data while template is instantiated template <unsigned long N> struct binary { std::cout << N;//<---------------------------------I'M TRYING HERE static unsigned const value = binary<N/10>::value << 1 // prepend higher bits | N%10; ...

C++ new line not translating

First off, I'm a complete beginner at C++. I'm coding something using an API, and would like to pass text containing new lines to it, and have it print out the new lines at the other end. If I hardcode whatever I want it to print out, like so printInApp("Hello\nWorld"); it does come out as separate lines in the other end, but if I r...

When is "this" pointer initialized in C++?

Hi I have a question about this pointer, when an object is constructed, when it is initialized? Which means, when can I use it? The virtual table is constructed in the constructor, is the same with this pointer? For example, I have a code like this. The output is 8. Does it mean that before the constructor is entered, this pointer is al...

How to programmatically gain root privileges ?

I am writing some software (in C++, for Linux/Mac OSX) which runs as a non-privileged user but needs root privileges at some point (to create a new virtual device). Running this program as root is not a option (mainly for security issues) and I need to know the identity (uid) of the "real" user. Is there a way to mimic the "sudo" comma...

C++: best way to implement globally scoped data

I'd like to make program-wide data in a C++ program, without running into pesky LNK2005 errors when all the source files #includes this "global variable repository" file. I have 2 ways to do it in C++, and I'm asking which way is better. The easiest way to do it in C# is just public static members. C#: public static class DataContain...

resource acquisition is initialization "RAII"

in the example below class X { int *r; public: X() { cout << "X is created"; r = new int[10]; }; ~X() { cout<< "X is destroyed"; delete [] r; }; }; class Y { public: Y() { X x; throw 44; }; ~Y() { cout << "Y is destroyed"; }; }; I got this ...

How default assignment operator works in struct?

Suppose I have a structure in C++ containing a name and a number, e.g. struct person { char name[20]; int ssn; }; Suppose I declare two person variables: person a; person b; where a.name = "George", a.ssn = 1, and b.name = "Fred" and b.ssn = 2. Suppose later in the code a = b; printf("%s %d\n",a.name, a.ssn); ...

What suggestions for a 3d game engine to support a huge terrain?

There are a lot of 3d game engines around, does anyone with experience with them have advice on which one would likely be able to handle these (arbitrary) requirements? opengl mac/pc 1000x1000km terrain 1000 towns varying in size from 10 to 1000 buildings 128 people in any one location MMO type networking (no solo play) physics engine ...