c++

How to compile a simple boost program from command line in unix

Say I have the path to the headers and lib files of boost, in $BOOST_INLCUDE and $BOOST_LIB how do I build a simple hello world? thanks ...

Migrating from Visual C++ 6 to Visual C++ 2008 express

Hi, I'm tring to migrate my code from VCpp 6 to VCpp 2008 express but when I build the solution I receive this error message: icl: warning: problem with Microsoft compilation of 'c:\Desenvolvimento\DFF\Base\\version.cpp' 1>C:\Arquivos de programas\Microsoft Visual Studio 9.0\VC\include\string.h(69): error: expected a ";" 1> __DEFINE...

C++0X Concepts are gone. Which other features should go too?

As you may have heard, the last meeting of the C++ standards committee voted to remove concepts from the next C++ standard. Of course, this will affect other features and would seem to throw the standard wide open again. If that is the case, which other features do you think should be stripped away (or added), and why? Links: Removal o...

where do you define typedef for complex maps?

General question: Where is usually defined class, namespace. My case: I am only using this maps in my class implementation: std::map<const std::pair<string, string>,const string*> and I wonder where is it good place to put it in the class (in public:) or in the enclosing header file? I don't have namespaces ...

Alternatives to LogonUser for network impersonation (C++)

Are there any alternatives to LogonUser and for impersonating given account in order to access network resources? I'm looking for the method of impersonation which would let me connect to machine in foreign domains (or, workgroup machines for the same matter). For initial data I have: machine name, username (or domain\username), cleart...

Anything like the c# params in c++?

That is the question. ...

std::vector resize downward

the C++ standard seems to make no statement regarding side-effects on capacity by either resize(n), with n < size(), or clear(). It does make a statement about amortized cost of push_back and pop_back - O(1) I can envision an implementation that does the usual sort of capacity changes ala CLRS Algorithms (eg double when enlarging, ha...

Assignment question in c++

Hello. Coming from c#, where classes instances are passed by reference(this is, a copy of the reference is passed when you call a function, instead of the integral value), I'd like to know how this works in c++. In the following case, _poly = poly; is copying the value of poly to _poly, or what? Thanks #include <iostream> #include <stdi...

How to add submenu to a CMenu in MFC?

I have an MFC app that uses CMenu for the main menu bar. I haven't been able to create submenus successfully. I can have the first level of File, Edit, View, etc and their sub menus, but I can't create a submenu off of one of those menus. For example, I would like to be able to go File->Recent Items->list of items in submenu I can do t...

c++ namespace collision with gtest and boost

If I include both gtest/gtest.h and boost/math/distributions/poisson.hpp I get /opt/local/include/boost/tr1/tuple.hpp:63: error: ‘tuple’ is already declared in this scope /opt/local/include/boost/tr1/tuple.hpp:67: error: ‘make_tuple’ is already declared in this scope /opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already dec...

I have the following usages of maps with pair as a key and it segfaults. Any Ideas?

I simpled the example to help with reability. Error follows the code: #include <map> #include<iostream> #include<string> using namespace std; class A { public: map<pair<string, string>, string* > m; string str; A():str("sdfsd") { m[make_pair("aa","bb")]=&str; ...

Must every test-case undo their operation at the end?

Hi, The question may be a little vague but here's an example of what I want to know (pseudocode): //start test-case for CreateObject function { // initialization of parameters MyObject *obj = CreateObject(); // test results } //end test-case for CreateObject function Is it necessary in this case to also deallocate the memory by calli...

C++ Newbie question: ThreadProc

Hi I am just trying to understand some source code written in C++. I am a bit familiar with C++, however, the following code sequence is absolutley new to me. A guess would be that here I register some thread routine with the kernel, ptest->Run(). Could that be right? static unsigned int __stdcall ThreadProc(void *lParameter) { CTe...

Function Call Guard

Suppose I have a free function called InitFoo. I'd like to protect this function from being called multiple times by accident. Without much thought I wrote the following: void InitFoo() { { static bool flag = false; if(flag) return; flag = true; } //Actual code goes here. } This looks like a big wa...

Where is <inttypes.h> in Visual Studio 2005?

I'd like to use the C99 header file inttypes.h in a Visual Studio project (I'd like to printf 64 bit numbers). However, this file does not seem to exist in my install. Is this just not part of VS2005? Are there any alternatives? ...

Overcoming bad habit of "fixing it later"

When I start writing code from scratch, I have a bad habit of quickly writing everything in one function, the whole time thinking "I'll make it more modular later". Then when later comes along, I have a working product and any attempts to fix it would mean creating functions and having to figure out what I need to pass. It gets worst b...

Create A Compiler For Windows

Possible Duplicate: Learning to write a compiler I'm learning C++ and as I know C++ is a very flexible language, it can make OS's and compilers, like the Python and the Ruby compilers, but I want to build my personal programming language, then I need some good tutorial for do this, I will be very happy if you can help me. ...

Way of overloading operator without changing original values?

I'm wondering if you can overload an operator and use it without changing the object's original values. Edited code example: class Rational{ public: Rational(double n, double d):numerator_(n), denominator_(d){}; Rational(){}; // default constructor double numerator() const { return numerator_; } // accessor double denomina...

Encapsulate Windows message loop into a DLL

I would like to have a DLL with window creation and management code in a way that the developer could just add a named main.h header and load the DLL to be able to instance a window. #include "dllheader.h" void user_main(); main = user_main; // attach user main to the dll callback int user_main() { Window *w = new Window(); } ...

Integrate Adobe AIR With C++

Hello, I'm learning C++ and before this i was reading some tutorials in the internet of the Adobe AIR development, but if Adobe AIR is so much easy to learn and C++ is a very flexible and good language it's possible to integrate those two languages in a same project. Thanks! ...