c++

Coupling an MFC CListCtrl and CTreeCtrl to get a view of the whole tree, not just one node at a time

Consider Windows Explorer (or regedit or similar). To the left side, there is a tree view, and to the right, a list view. In all cases I know of, the contents of the right view reflect the attributes of the selected node from the left pane. This is all well and good... but just not what I want. The nodes of the tree I want to display ha...

"'assert’ was not declared in this scope" in MySQL++

I'm compiling a project in XCode where MySQL++ in included and linked to. For some reason, I keep getting the following compiler error: 'assert’ was not declared in this scope originating from cpool.h, a header file that's part of MySQL++. Does anyone know why this is being triggered? EDIT: For reference, MySQL++ was installed via M...

How to add custom line endings in text file (e.g. I want to add a line ending after all periods)

I have a bunch of text files where I want to add a line ending after each period. I'm wondering if there is a way to do this by doing replacing all periods with a \n\n, assuming I have the right encoding (unix). Anyone know how I would do this? Replace .'s with .\n\n and then save as a different file? Thanks! ...

Disable MSBuild output of "Processing /ORDER options..."

The output file from our project build has gone from 6MB to over 75MB in text. Diff'ing the last good build and the first time it blew up, there's a section in the output file like this in the latest: Processing /ORDER options External code objects not listed in the /ORDER file: ?onCallDisconnected@CallStateConnected@CallImpl@space...

C++ floating point precision

Possible Duplicate: Floating point inaccuracy examples double a = 0.3; std::cout.precision(20); std::cout << a << std::endl; result: 0.2999999999999999889 double a, b; a = 0.3; b = 0; for (char i = 1; i <= 50; i++) { b = b + a; }; std::cout.precision(20); std::cout << b << std::endl; result: 15.000000000000014211 So.. ...

Access cost of dynamically created objects with dynamically allocated members

I'm building an application which will have dynamic allocated objects of type A each with a dynamically allocated member (v) similar to the below class class A { int a; int b; int* v; }; where: The memory for v will be allocated in the constructor. v will be allocated once when an object of type A is created and will never need t...

Strange error with CreateCompatibleDC

Maybe this is a foolish question, I can't see why I can not get a DC created in the following code : HBITMAP COcrDlg::LoadClippedBitmap(LPCTSTR pathName,UINT maxWidth,UINT maxHeight) { HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, pathName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); ...

Bona fide transiant windows with WinAPI?

I want to create a Window like when a context menu pops up or clicking the menubar. I want a Window that will be like this and that I can take over its paint event. Sort of like what is created when you select a sub tool in Photoshop. EDIT:I want to know how to create controls like the one that comes when you select a sub tool in Photo...

weird performance in C++ (VC 2010)

Hello, I have this loop written in C++, that compiled with MSVC2010 takes a long time to run. (300ms) for (int i=0; i<h; i++) { for (int j=0; j<w; j++) { if (buf[i*w+j] > 0) { const int sy = max(0, i - hr); const int ey = min(h, i + hr + 1); const int sx = max(0, j - hr); c...

Few Basic Questions in Overriding

I have few problems with my basic and would be thankful if someone can clear this. 1: What does it mean when I say base *b = new derived; Why would one go for this? We very well separately can create objects for class base and class derived and then call the functions accordingly. I know that this base *b = new deriv...

Is there any way to use VC++ 2010 without including stdafx.h?

Hi all, I've successfully installed M$ VC2010 and start writing simple programs using it. I am very annoyed from the #include<stdafx.h>, So is there any way to compile and run programs without it??? ...

Why this base64 function stop working when increasing max length?

I am using this class to encode/decode text to base64. It works fine with MAX_LEN up to 512 but if I increase it to 1024 the decode function returns and empty var. This is the function: char* Base64::decode(char *src) { unsigned six, dix; unsigned int d_len = MAX_LEN; memset(dst,'\0', MAX_LEN); unsigned s_len = strle...

Compiling cpp code in netbeans produce errors, how to solve it ?

i use the netbeans with MinGW and MYSY make /debugger but when i compile a basic cpp code in it and run it it produces two erorrs this is the code runned and the output![alt text][1] box #include <iostream> void main() { cout << "Hello World!" << endl; cout << "Welcome to C++ Programming" << endl; } output is /usr/bin/make -...

Can't inherit from auto_ptr without problems

What I want to do is this: #include <memory> class autostr : public std::auto_ptr<char> { public: autostr(char *a) : std::auto_ptr<char>(a) {} autostr(autostr &a) : std::auto_ptr<char>(a) {} // define a bunch of string utils here... }; autostr test(char a) { return autostr(new char(a)); } void main(int args, char **ar...

How do I seperate Punctuations in a sentence with a space between each phrase and punctuation in C++?

I want to write a program in c++ that get a sentence and insert a space between each word and punctuation in it! in sed script this is done with this expression: sed -e "s/,\([^0-9]\)/ , \1/g" -e "s/\.\([^0-9]\)/ . \1/g" -e 's/\.[ ]*$/ ./g' -e "s/\'/ \' /g" -e 's/?/ ?/g' -e 's/\`\`/ `` /g' -e "s/\' \'/''/g" -e 's/(/ ( /g' -e 's/)/ ) /g...

Global variable not stable after platform changed.

Our embedded system is built on a hw/sw platform made by enea. After the platform updated recently, we found some operations on the global variable keep crashing the system. For example, we have a global map structure holding some data. We can insert/iterate the map once or twice, then the address of the elements in the map suddenly ch...

OpenGL Not drawing

I am using GLFW as GUI for OpenGL projects. I am using my red book and testing code and well the first bit of code doesn't work at all. I want to say this is a GLFW problem because I don't have this problem in JOGL. #include <iostream> #include "GL/glfw.h" #ifndef MAIN #define MAIN #include "GL/gl.h" #include "GL/glu.h" #endif using nam...

c++ manipulator question

i have a class: template<class T> class matrix { private: int COLS,ROWS; public: inline matrix(int r,int c){ this->COLS=r; this->ROWS=c; } template<class T2> friend ostream& info(ostream& os); }; i tried in so many ways to implement the info function.but none is succeed. i want to use it in main f...

Get home directory in Linux, C++

I need a way to get user home directory in C++ program running on Linux. If the same code works on Unix, it would be nice. I don't want to use HOME environment value. AFAIK, root home directory is /root. Is it OK to create some files/folders in this directory, in the case my program is running by root user? ...

Switch/Case statements in C++

Regarding the switch/case statement in the C++ code below: "Case 1" is obviously false, so how/why does it enter the do-while loop? #include <iostream> using namespace std; int main() { int test = 4; switch(test) { case 1: do { case 2: test++; case 3: test++; case 4: cout << "How...