c++

Unsticky a cout modifier?

cout << hex << 11 << endl; cout << 12 << endl; will print : a b If I cout 13, it will be printed as 'c'. How do I remove the hex modifier from now on so it would just print 13? This is probably simple but I tried looking for the answer elsewhere. Thanks. ...

How to get a pointer out of scope

This is not exactly my code but it looks a lot like it I have 2 tables of type CTable. They work in the same way as normal arrays but can be allocated dynamically and resized. So lets just pretend that they are arrays right now One table has object references MyObj obj1; MyObj obj2; MyObj table1[10]; table1[0] = obj1; table1[1] = obj...

Boost c++ library install

I am not familiar with the usual build technique in linux I am using boost c++ library. Can any body guide me in installing and configuring boost c++ library. Thanks in advance ...

Adding boost::ptr_vector to deque, typeid mismatch

I'm trying to add a boost::ptr_vector to a std::deque, using push_back(). When I do, I get a BOOST::ASSERT for the typeid mismatch. In "boost_ptr_container_clone_allocator" T* res = new T( r ); BOOST_ASSERT( typeid(r) == typeid(*res) && "Default new_clone() sliced object!" ); return res; From TotalVi...

How do you "break" out of a function?

Given a function that returns a value, is it possible to exit the function given a certain condition without returning anything? If so, how can you accomplish this? Example: int getNumber () { . . . } So say you are in this function. Is there a way to exit it without it doing anything? ...

Calculate height of a tree

I am trying to calculate height of a tree. I am doint with the code written below. #include<iostream.h> struct tree { int data; struct tree * left; struct tree * right; }; typedef struct tree tree; class Tree { private: int n; int data; int l,r; public: tree * Root; Tree(int x) { n=x; ...

Does C++ have "with" keyword like Pascal?

with keyword in Pascal can be use to quick access the field of a record. Anybody knows if C++ has anything similar to that? Ex: I have a pointer with many fields and i don't want to type like this: if (pointer->field1) && (pointer->field2) && ... (pointer->fieldn) what I really want is something like this in C++: with (pointer) { ...

c++ namespace export

Is there a way in C++ to create an anonymous namespace, and only export a single function out of it? I want something like: namespace { void Bar() {} void Foo() { Bar(); } } Now, I want to somehow access to Foo() yet make sure there's no way to touch Bar() Thanks! ...

Using STL inside ATL

hi, I need to use tree structure inside a ATL COM server. I thought of using stl::map<> for this purpose as follows. BaseMap[k1,NextLevelMap[k2, NextLevelMap[k3, Value]]] But I need to know, whether using such a structure inside ATL is safe and possibility of debugging support with maps. Thank you ...

encapsulation, data-hiding, setters/getters in c++

Possible Duplicate: Why use getters and setters? while writing class in c++, usually methods are made public, and attributes are made private/public, so that these attributes cant be accessed from outside. But when we use getters/setters, these attributes can be easily accessed,modified from outside. So, why to make them priv...

Profiling a C or C++ based application that never exits

Hi I have a small doubt regarding profiling applications which never exit until we manually reboot the machine. I used tools like valgrind which talks about memory leaks or bloating of any application which exits after sometime. But is there any tool which can be used to tell about memory consumption, bloating, overhead created by t...

popup not active window gets activated

Hi, I've a popup window which I show with the SW_SHOWNA flag. If I click parts of this window, I catch the click and then close it, the problem is, there are other parts of the window and I don't want to close the window on click on them, but when I click them the window gets activated and gets the focus, that's bad for me, I want this ...

smtp mail sending

i want to integrate smtp mail sending option in my vc++ application please any one provide the class or lib whch can be integrated ...

Good coding guidelines tool for C++?

Possible Duplicate: What tools exist for comparing C++ code to coding guidelines? Can any one suggest any good coding guidelines tool for C++ which must be configurable according to specific requirements? ...

Linker fails to link my application (XXXX already defined in XXXX.obj)

When I try to build my application the linker gives loads of errors like this one: modlauch.obj : error LNK2005: "public: virtual __thiscall lolbutton::~lolbutton(void)" (??1lolbutton@@UAE@XZ) already defined in lolbutton.obj I suspect it has something to do with misconfigured compiler but I don't know how to fix it. My cla...

Vkontakte UserAPI examples on C++

Say me please, where i can find examples on C++ with using UserAPI Vkontakte? ...

expected nested-name-specifier before 'sktraits'

This is a snippet of a class template which is causing compilation errors: /* Secondary index class */ template<class TKey, class TVal, class key_traits, class val_traits> template<class TSecKey, class sktraits> class CBtreeDb<TKey, TVal, key_traits, val_traits>::CDbSecondaryIndex: protected CBtreeDb<TKey, TVal>, public IDeallocateKey ...

c++ threadsafe static constructor

Given: void getBlah() { static Blah* blah = new Blah(); return blah; } In a multi threaded setting, is it possible that new Blah() is called more than once? Thanks! ...

Is .NET "all COM underneath"?

I've been an admirer of Juval Lowy's teaching and guidance in .NET development for a number of years. He's also written one of my favorite books: Programming .NET Components. However on a recent DotNet Rocks podcast (Jan 2010) in discussing WCF/COM and .NET, he made some comments that greatly surprised me: Juval Löwy: ..... in .N...

vector reserve c++

I have a very large multidimensional vector that changes in size all the time. Is there any point to use the vector.reserve() function when I only know a good approximation of the sizes. So basically I have a vector A[256*256][x][y] where x goes from 0 to 50 for every iteration in the program and then back to 0 again. The y values ca...