c++

Function Pointer from base class

Hi there, i need a Function Pointer from a base class. Here is the code: class CActionObjectBase { ... void AddResultStateErrorMessage( const char* pcMessage , ULONG iResultStateCode); ... } CActionObjectCalibration( ): CActionObjectBase() { ... m_Calibration = new CCalibration(&CActionObjectBase::AddResultStateErrorMessage); ...

boost.test and eclipse

Hi all, I'm using Eclipse CDT and Boost.Test(with Boost.Build). I would like Eclipse to parse output of Boost.Test generated during by run of test suites during build. Does anybody know how to achieve this? Thanks in advance ...

We say Reference are const pointers. Why I am able to assign a new variable to ref B? The below program compiles successfully.

#include<iostream.h> int main() { int a=10; int &b=a; cout<<"B"<<'\n'<<b; cout<<"A"<<'\n'<<a; b=100; cout<<"B"<<'\n'<<b; cout<<"A"<<'\n'<<a; int c=20; b=c; cout<<"C"<<'\n'<<c; cout<<"B"<<'\n'<<b; } ...

May volatile be in user defined types to help writing thread-safe code

I know, it has been made quite clear in a couple of questions/answers before, that volatile is related to the visible state of the c++ memory model and not to multithreading. On the other hand, this article by Alexandrescu uses the volatile keyword not as a runtime feature but rather as a compile time check to force the compiler into fa...

Why does gcc think that I am trying to make a function call in my template function signature?

GCC seem to think that I am trying to make a function call in my template function signature. Can anyone please tell me what is wrong with the following? 227 template<class edgeDecor, class vertexDecor, bool dir> 228 vector<Vertex<edgeDecor,vertexDecor,dir>> Graph<edgeDecor,vertexDecor,dir>::vertices() 229 { 230 return V; 231 }; GCC i...

copy constructor by address

I have two copy constructors Foo(Foo &obj){ } Foo(Foo *obj){ } When will the second copy constructor will get called? ...

how to view contents of STL containers using GDB 7.x

I have been using the macro solution, as it is outlined here. However, there is a mention on how to view them without macros. I am referring to GDB version 7 and above. Would someone illustrate how? Thanks ...

Output unicode strings in Windows console app

Hi I was trying to output unicode string to a console with iostreams and failed. I found this: Using unicode font in c++ console app and this snippet works. SetConsoleOutputCP(CP_UTF8); wchar_t s[] = L"èéøÞǽлљΣæča"; int bufferSize = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL); char* m = new char[bufferSize]; WideChar...

Gradient fill bitmap and CreatePatternBrush just gives black fill instead of gradient

I'm trying to create a Gradient Brush in windows mobile as follows: HBITMAP hBitmap = CreateBitmap(16, 16, 1, 16, NULL); HDC hDC = CreateCompatibleDC(NULL); HBITMAP hPrevious = SelectObject(hDC, hBitmap); TRIVERTEX vert[2]; GRADIENT_RECT gRect; //... fill in vert and gRect GradientFill(hDC, vert, 2, &gRect, 1, GRADIENT_FILL_RECT_V); Sel...

Is it undefined behavior in the case of the private functions call in the initializer list?

Consider the following code: struct Calc { Calc(const Arg1 & arg1, const Arg2 & arg2, /* */ const ArgN & argn) : arg1(arg1), arg2(arg2), /* */ argn(argn), coef1(get_coef1()), coef2(get_coef2()) { } int Calc1(); int Calc2(); int Calc3(); private: const Arg1 & arg1; const Arg2 & arg2; // ... const...

error in C++, what to do ?: could not find an match for ostream::write(long *, unsigned int)

I am trying to write data stored in a binary file using turbo C++. But it shows me an error could not find an match for ostream::write(long *, unsigned int) I want to write a 4 byte long data into that file. When i tries to write data using char pointer. It runs successfully. But i want to store large value i.e. eg. 2454545454 Which ...

get local time with boost

Hi guys, I didn't find this in documentation: how to get local time (better formatted) with boost? ...

#include headers in C/C++

After reading several questions regarding problems with compilation (particularly C++) and noticing that in many cases the problem is a missing header #include. I couldn't help to wonder in my ignorance and ask myself (and now to you): Why are missing headers not automatically checked and added or requested to the programmer? Such feat...

C++ Reserve Memory Space

is there any way to reserve memory space to be used later by default Windows Memory Manager so that my application won't run out of memory if my program don't use space more than I have reserved at start of my program? ...

boost::multi_array resize exception?

I'm trying to figure out if the boost::multi_array constructor or resize method can throw a bad_alloc exception (or some other exception indicating the allocation or resize failed). I can't find this information in the documentation anywhere. Clarification (added from comment): This is a scientific algorithm that can fall back to a l...

OpenGL: Disable texture colors?

Is it possible to disable texture colors, and use only white as the color? It would still read the texture, so i cant use glDisable(GL_TEXTURE_2D) because i want to render the alpha channels too. All i can think of now is to make new texture where all color data is white, remaining alpha as it is. I need to do this without shaders, so ...

Which type of design pattern should be used to create an emulator?

I have programmed an emulator, but I have some doubts about how to organizate it properly, because, I see that it has some problems about classes connection (CPU <-> Machine Board). For example: I/O ports, interruptions, communication between two or more CPU, etc. I need for the emulator to has the best performance and good understandi...

Pitfalls when converting C++/CLI to C++

I have a library written in C++/CLI and I want to open it up. I want it to be as cross-platform as possible and be able to write bindings to it for other languages to use (Java, Python, etc, etc). To do this, the library needs to be in plain C++ for maximum flexibility. I figure that the logical structures are already there, I just need ...

C++ is there a difference between assignment inside a pass by value and pass by reference function?

Is there a difference between foo and bar: class A { Object __o; void foo(Object& o) { __o = o; } void bar(Object o) { __o = o; } } As I understand it, foo performs no copy operation on object o when it is called, and one copy operation for assignment. Bar performs one copy operation on object o when it is ...

Is there a way to use Qt's unit testing modules as part of a Code::Blocks project with the QtWorkbench plugin?

We're developing a Qt project using the Code::Blocks IDE with the QtWorkbench plugin. We'd like to take advantage of Qt's unit testing modules to test our code, but from what I've read online, the only way to do so is to use qmake to manually create a new "project" and makefile for each unit test and then to build and execute that projec...