c++

How to write your own condition variable using atomic primitives

I need to write my own implementation of a condition variable much like pthread_cond_t. I know I'll need to use the compiler provided primitives like __sync_val_compare_and_swap etc. Does anyone know how I'd go about this please. Thx ...

Changing CFrameWnd to CFrameWndEx in MFC causes unhandled exception - any ideas?

Still getting used to this MFC lark and I've hit a brick wall on this particular problem. I'm updating some legacy code to use some of the more refined controls available in the MFC Feature Pack. Following the examples given online for updating an old MFC app, changing the base application class to CWinAppEx works fine, but when I chan...

Compiling on Windows and Mac with Autotool

I have a problem trying to use autotools for a simple contrived project, the task is simple, use Objective-C on Mac OSX, and C++ on Windows (mingw) - with some C glue in the middle. The project is structured like so (minus all the automatically generated files): ./aclocal.m4 ./configure ./configure.ac ./Makefile.am ...

What's a good C++ code design for a one Template Object -> multiple Instance Objects architecture?

I have the following design request for a visual editing tool written in C++: be able to define a template object (assign image, edit default rotation/scale, edit default property values) be able to place instances of template object in view be able to make changes to template object (eg different image, change rotation, scale, propert...

Extending homework testing platform to include code analysis (C/C++)

I'm maintaining/developing a platform for homework testing. It's mostly automatic. What I need to add now is code analysis. I need to check the code for specific constructs. For example: Does the file main.cpp contain a class named user with a const method get_name()? Is there some tool out there that would allow me to do suc...

How to generate random numbers in C++ using <random> header members?

I learned to program in C# and have started to learn C++. I'm using the Visual Studio 2010 IDE. I am trying to generate random numbers with the distribution classes available in <random>. For example I tried doing the following: #include <random> std::normal_distribution<double> *normal = new normal_distribution<double>(0.0, 0.0); s...

How can I ensure that a class has no virtual methods?

I have a class whose objects are used in shared memory. Therefore, I must be sure that they do not have virtual methods (which crash the program when called via vtable). I would like to guard against anybody accidentally adding a virtual method in violation of this requirement. Ideally, the compiler would refuse to even compile the clas...

Simplest lua function that returns a vector of strings

Hi guys, I need a very simple c++ function that calls a lua function that returns an array of strings, and stores them as a c++ vector. The function can look something like this: std::vector<string> call_lua_func(string lua_source_code); (where lua source code contains a lua function that returns an array of strings). Any ideas? Th...

IWebBrowser2 interfaces dependency graph

Is there interfaces dependency graph for IWebBrowser2 component? I just want to make it clear what kind of dependencies exist between interfaces and who calls who? ...

C++ STL list operator overloading for pairs (sorting according to first value, accessing with second value)

Hello I have some touble overloading operators for std::list. I store pairs in a list, consisting in an int value and a position array : typedef std::pair< int, std::vector<int,3> > pointPairType; typedef std::list< pointPairType > pointListQueueType; pointListQueueType pointsQueue; // adding some points to the list And I wou...

How to read c++ errors involving templates.

I'm learning C++. I regularly get errors that look like this /usr/lib/gcc/i686-pc-cygwin/4.3.4/include/c++/bits/basic_string.h:1458: instantiated from 'static _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct_aux(_InIterator, _InIterator, const Alloc&, std::_false_type) [with _InIterator = std::istream_iterator, std...

vc++ installing libcurl

Hey, firstly thanks for reading this. I am a bit of a noobie c++ programmer with a great idea. For programming this I need to download some HTML off websites. I have chosen libCurl due to perform this task. The libcurl website is of little help to me. Most of the information on their website is outdated or deviates slightly. So, some mo...

Asynchronous threads in standard C++

Hi, I wonder how could I implement an asynchronous call in standard C++. I have a image/video processing program and I want to add another function/feature but I would like it to be run in a another thread or to be run asynchronously to the original thread. I just want to notify the main thread when something happened in this new threa...

How can i free a pointer vector?

Hello, how can i free up memory in a pointer vector? Here's the code: class A { private: int x,y,z; public: A(param1, param2, param3) { x=param1; y=param2; z=param3; } ~A() { //prompts an alertbox, warning me about the successful call...

Problem with Policies

#include "stdafx.h" #include <exception> template<class T> class NoCheck; template<class T> class EnforceNotNull { public: //EnforceNotNull(const NoCheck<T>&){}//<<-----If this is uncommented it works static void Check(T* p) { class NullPtrException : public std::exception { }; if (!p) ...

How does Boost.Python work?

How is Python able to call C++ objects when the interpreter is C and has been built w/ a C compiler? ...

boost.serialization - free version and base class implementation.

I have a "generator" class that basically constructs its subclass. To use this thing I simply subclass it and pass it the correct parameters to build the object I want built. I want to serialize these things and there's no good reason to do it for each subclass since all the data is in the base. Here's what I've got as example: #incl...

Return value of ifstream.peek() when it reaches the end of the file

I was looking at this article on Cplusplus.com, http://www.cplusplus.com/reference/iostream/istream/peek/ I'm still not sure what peek() returns if it reaches the end of the file. In my code, a part of the program is supposed to run as long as this statement is true (sourcefile.peek() != EOF) where sourcefile is my ifstream. Howeve...

how C++ ensures the concept of base class and derived class

Hi, I would like to know how c++ ensures the concept layout in memory of these classes to support inheritance. for example: class Base1 { public: void function1(){cout<<"Base1"}; }; class Base2 { public: void function2(){cout<<"Base2"}; }; class MDerived: Base1,Base2 { public: void function1(...

Retrieving the color of a given pixel in Gtk+/Gtkmm

Which is the best and fastest way to retrieve the color of a given pixel of a widget? For example: I load an image onto a Gtk::DrawingArea or draw something on it. Then I try to retrieve the color of the pixel that the mouse cursor is over. I use this technique: bool MainWindow::on_canvas_motion_notify(GdkEventMotion* event) { get_...