c++

pointers to derived members of the class

hello to everyone, if I have for example some class Base and derived from it Derived Also I have some list of shared pointers: list<shared_ptr<Base> > list I create shared pointer: line 5 shared_ptr<Derived> ptr(new Derived(//some constructor)); my question is, can I do something like this: list.push_back(ptr); if Yes, can s...

"non-existent member function specified as friend" - ??

Hi, I'm trying to compile CSSTidy with Visual Studio. The problem is that it throws error C2245: non-existent member function 'umap::erase' specified as friend (member function signature does not match any overload) pointing to the friend void umap<keyT,valT>::erase(const typename umap<keyT,valT>::iterator& it); which is a de...

Casting from any

Hello, I'm packing some classes into ptr_map with any typed value. class EventManager { ptr_map<string, any> mSomeMap; public: typedef signals2::signal<void (int someSignature)> KeyEvent; EventManager() { mSomeMap["KeyPressed"] = new any(new KeyEvent()); } }; Now I want to restore my signal objec...

How to compile code generated by a Java or C++ App

I've been learning compiler theory and assembly and have managed to create a compiler that generates x86 assembly code. How can I take this assembly code and turn it into a .exe? Is there some magical API or tool I have to interact with? Or is it simpler than I think? I'm not really sure what's in a .exe, or how much abstraction lies b...

undefined behavior in c++

Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc) why this code have different answer in different compiler? int u=10,k; k=(++u)+(++u)+(++u); printf("k=%d ",k); (for example in dev compiler : k=37 ) ...

STL Priority Queue - deleting an item

Hello, I want to implement a timer queuing system using the C++ STL priority_queue container adapter. My problem is that I want to occasionally cancel a timer, however there are no interfaces that enable me to easily delete an item in the priority_queue that is not the top item. Any suggestions?. Thank you for your help. ...

enable_if and conversion operator?

Any chance to use enable_if with a type conversion operator? Seems tricky, since both return type and parameters list are implicit. ...

problems with dynamic_cast

hello, I have this snippet of the code: void addLineRelative(LineNumber number, LineNumber relativeNumber) { list<shared_ptr<Line> >::iterator i; findLine(i, number); if(i == listOfLines.end()){ throw "LineDoesNotExist"; } line 15 if(dynamic_cast<shared_ptr<FamilyLine>...

No instance of constructor --- Matches Argument List (Templating issue maybe)

Hey S.O. Guys I am currently trying to write a basic wrapper for the cml (http://www.cmldev.net/) math library for a project i am working on. I have a wrapper for the cml vector class which has one private member #ifndef VECTOR3_H_ #define VECTOR3_H_ #include "cml\cml.h" #include <memory> namespace Math { template<typename T> ...

Application settings with WinAPI

Is there any standard way to work with application settings in WinAPI? What I'm doing currently is this: if(!ReadKey(some_setting)) WriteKey(some_setting, some_setting_setting_default_value) when the settings dialog is initialized. Then I set the widget states to the corresponding values read from the registry. The problem is that...

does DEFINE Macro work on all platforms ???

I am a newb and I am trying to better myself at good practice and design so consider this before reading the following. I am creating a singleton class, and I have quite a few static members. Instead of calling the members every time like this... THECLASS::member I was thinking about using a define macro to make it shorter. #define...

Good tutorial to create Win32 toolbar?

I want to add a toolbar and know which tool was clicked. I'd also like to be able to change the toolbar's buttons' bitmap after theyve been created MSDN is fairly breif on all of this. Thanks ...

Converting a void* to a std::string

After perusing the web and messing around myself, I can't seem to convert a void*'s target (which is a string) to a std::string. I've tried using sprintf(buffer, "%p", *((int *)point)); as recommended by this page to get to a C string, but to no avail. And sadly, yes, I have to use a void*, as that's what SDL uses in their USEREVENT stru...

Weird c++ input escaping and space behavior

I'm having an unpleasant problem with my c++ example. Everything works fine until I enter something with a whitespace. #include <iostream> using namespace std; int main (int argc, char * const argv[]) { int iteration = 0; while (true) { char * input = new char[256]; scanf("%s", input); cout << ++iteratio...

Game Development: Should I program my levels or interpret them from a file?

The title says it all... The game will be written in C++ Programming: enemies.puch_back(new DefaultEnemy(200, 300, 3, 5)); enemies.puch_back(new DefaultEnemy(500, 400, 4, 5)); enemies.puch_back(new DefaultEnemy(300, 420, 3, 15)); enemies.at(2).createAward(new Key(4), "pling.wav"); Or Interpret them from a file like this: DefaultEnem...

Type requirements for std::list

I've got a type that can't be moved or copied (by making the necessary constructors and operators private). But when I tried to compile a std::list of them, the operation failed with a very strange error (class name snipped for brevity). 1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xmemory(202) : error C2248: 'T::T' ...

Derived classes and singleton

Hello all, If I have two classes "A" and "B", is it OK to derive B from A and then make B a Singleton?. Thanks for your help. ...

C++ counting execution time eror

Hi, I'm trying to count the execution of function in my code (that takes over an hour), and I'm using clock(), but I'm getting some errors, since the time calculated is negative. I'm doing like this: long double time; clock_t start, t_end; t_start = clock(); algorithm->execute(); t_end = clock(); time = ((long double) t_end - t_start)...

SWIG support for inheritance of static member functions

SWIG doesn't wrap inherited static functions of derived classes. How it can be resolved? Here is a simple illustration of the problem. This is a simple C++ header file: // file test.hpp #include <iostream> class B { public: static void stat() { std::cerr << "=== calling static function B::stat" << std::endl; } void nonstat() c...

Sharing violation on file which really should be closed

I have an application that modifies an XML file by: (a) opening it, (b) creating a temporary file and writing a modified version to it, (c) closing both files, and (d) replacing the original file with the temporary file. When I test it on my laptop running Vista, everything works just as it should. On an embedded PC running XP Profe...