c++

Can I destruct a structure in C++?

Is there a way to destruct a structure (not a class)? ...

C code changes terminal text color; how to restore defaults? Linux

I have a C file running on Linux. It prints some lines in red (failures) and some in green (passes). As you might expect, it uses escape codes in the printf statements as follows: #define BLACK "\033[22;30m" #define GREEN "\033[22;31m" printf(GREEN "this will show up green" BLACK "\n"); If the BLACK at the end wasn't there, the ter...

C++ - building libraries

Hello! I'm building static libraries (right now libpng) in Microsoft Visual Studio 2008 SP1. Do I have any possibility to build single library (one file) for both Debug and Release modes assuming that my library has only C code in it? As far as I remember, gtkmm, for instance, has it's pre-built package, where C++ based libraries are ...

boost regex matching question

Hi, I want to test a regular expression with boost: const wregex regex_comment(L"^\\s*#.*"); //regexpr for comment My problem - it does not match a widestring consisting of: #This is a comment can someone give me a hint why or where I can look for the error? hm - it seems to work in the non-Unicode version. I'm using boost 1.42, s...

C++ double buffer and memory

Ok so my double buffer works fine but it seems that it use a lot of memory. i know that double buffer should store a copy of the ellipse I'm drawing than paint it on the screen but it after that it deletes the copy and makes new copy but it doesn't seem to delete it here is my code hdc=GetDC(hWnd); HDC memDC=CreateCompatibleDC(hdc); H...

TR1 from Boost or VC10 - Which one is better?

I'm currently migrating from Visual Studio 2008 to 2010. My software makes heavy use of Boost and it's TR1 features. I now get a lot of compiler errors, because VC10 has it's own TR1 implementation. I know I can disable Microsoft's TR1 implementation with the _HAS_CPP0X switch (see here), but I'm not sure if this also disables other fea...

pinvokestackimbalance -- how can I fix this or turn it off?

I just switched to vs2010 from vs2008. Exact same solution, except now every single call to a C++ dll yields a 'pinvokestackimbalance' exception. This exception does not get fired in 2008. I have complete access to the C++ dll and to the calling application. There does not appear to be any problem with the pinvoke, but this problem i...

Object is already initialized on declaration?

I'm trying to understand something in C++. Basically I have this: class SomeClass { public: SomeClass(); private: int x; }; SomeClass::SomeClass(){ x = 10; } int main() { SomeClass sc; return 0; } I thought that sc is an uninitialized variable of type SomeClass, but from the various tutorials I fo...

undefined reference to `Class::Class()'

Hello, I am writing a GTKmm window program; the main window creates two buttons, one for English and one for Chinese. The user can click on the button to bring up a different window in the appropriate language. Currently I am having trouble initializing the multiple-item container inside the main window. It is an object of type MainWindo...

Input Box in an MFC CWinApp prgram?

I need an input box in a UI program that is already written derived from the CWinnApp class and using MFC. I see it is using message boxes but I don't see any examples of input boxes.... How do I do this? (Using Visual Studio 6.0 in C++) Thank You. ...

order of destruction using virtual

Can some one please help what the order of destruction is when I am using virtual functions. Does it start with base class and then derived class ? ...

Good (preferable free) learning resources / books for embedded C / C++ programmers.

Well, initial reason I ask this question is I need from time to time learning materials for struggling C / C++ developer who is in general competent but needs to improve some aspect directly related to embedded system software development (telecom mainly). And I found I have not so many useful things to recommend. Could community help w...

white space free path to My Documents

Hello All, In building a C++ project with the GNU tool chain, make tells me ~ src/Adapter_FS5HyDE.d:1: * multiple target patterns. Stop. Search, search, search, and I found out that make thinks that it has multiple targets because the path to my included headers has spaces in it. If you've got your headers stored in some sane p...

Accessing C# user settings from a C++ Application

I am writing a C# program in Microsoft Visual Studio 2010 that stores some information inside of the local user settings like so: Properties.Settings.Default.userActive.Add(connection.Active); Properties.Settings.Default.Save(); I also have a Visual C++ application that would like to read these stored user settings. Is it possible f...

Change background color of another program from C++ program

I'm trying to change the background color of a program I did NOT write. Looking at it with Spy++ I can see that the main class is "ThunderRT6FormDC". One of its children has the class "ThunderRT6Frame". Inside ThunderRT6Frame there are a bunch of ThunderRT6CommandButtons. I want to change the background color behind the buttons. I trie...

When I derive a class in C++, does it create an object of base class and store it as my member variable in derived class?

Say i create a derived class as below, class CHIProjectData : public QObject { CHIProjectData(QMap<QString,QString> aProjectData, CHIMetaData* apMetaData = 0, QObject* parent = 0); private: QMap<QString,QString> m_strProjectData; CHIAkmMetaData* m_p...

How to truncate HWND title

I am creating a window which opens to a dynamic title. I would like to have the window's title truncate if the window is resized and there isn't room to show the full title. For example, I have HWND handle = GetHWND(); // gets me the correct handle std::wstring title = L"some fairly long window title"; SetWindowTextW(handle, title.c_s...

'QObject::QObject' cannot access private member declared in class 'QObject'

class CHIProjectData : public QObject { public: CHIProjectData(); CHIProjectData(QMap<QString,QString> aProjectData, CHIAkmMetaData* apAkmMetaData = 0, QObject* parent = 0); private: QMap <QString,QString> m_strProjectData; CHIAkmMetaData* m_pAkmMetaData; }; CHIProjectData::CHIProjec...

c++ handling derived class that's self referencing

So suppose I have a tree class like this in c++ class Node{ void addChild(Node*); /*obvious stuff*/ protected: Node* parent; vector<Node*> children } class specialNode : public Node{ void addChild(specialNode*); /*obvious stuff*/ /*special stuff*/ } Now whenever I access the children in special...

variable of class A in class B and pointer of class B in class A?

This may seem weird but I have a problem in one of my programs where I have a class A which needs a variable of class B inside it, and the class B needs a pointer to class A inside it, so that i can determine which class is attached to what.... i get errors because in class A it says that the class B is not defined yet, and in class B i...