c++

Basic polynomial reading using linked lists

Ok, after failing to read a polynomial, I'm trying first a basic approach to this. So i have class polinom with function read and print: #ifndef _polinom_h #define _polinom_h #include <iostream> #include <list> #include <cstdlib> #include <conio.h> using namespace std; class polinom { class term { public: double...

Customizing CGAL Kernel with my own Point class

I would like to use a custom Point class with the CGAL constrained delaunay triangulation. However, with the following MyPoint class (which should behave the exact same as a CGAL::Point_2 no?) I get segmentation faults. It works perfectly if I set the Point_2 typedef inside MyKernel to CGAL::Exact_predicates_inexact_constructions_kernel:...

Fastest C++ Signal/Slot Lib without dependency

I am going to pass data up/down a 5-10 layered object using signals and slots. Which should result in a few thousand signal per sec. Which is far form "I clicked a button". All my object will also signal them self on a timer about every 100ms so they can do some processing. What would be the fastest C++ Signal/Slot implementation which ...

Trying to switch a texture when player dies (OpenGL + C++)

I'm creating a 2D game and when the player dies I want the texture I to switch to another (to show an explosion) I also want the game to pause for a second or two so the user can see that the texture has changed. My textures are loading correctly because I can apply it to a shape and i can see it if I say switched it with the players or...

Empty Win32 Popup Menu

I'm trying to create a dynamic popup menu within my application, the generation code I use is something like that : HMENU menu; POINT pt; menu = CreatePopupMenu(); SetForegroundWindow( receivingWindow ); GetCursorPos( &pt ); int i = 19; AppendMenu( menu, MF_STRING, i++, _TEXT("meh meh") ); AppendMen...

CreateDIBSection leaving 'Not enough storage' error, but seems to still work anyway

Whenever my app tries to create a DIB section, either by calling CreateDIBSection(), or by calling LoadImage() with the LR_CREATEDIBSECTION flag, it seems to return successfully. The HBITMAP it returns is valid, and I can manipulate and display it just fine. However, calls to GetLastError() will return 8: Not enough storage is availabl...

Compiling boost on Sunos

I have just started with using boost libraries. For one of our projects i want to compile Boost 1.39.0 on Sun OS using sun compiler. However if i compile it using steps mentioned in http://www.boost.org/doc/libs/1_39_0/more/getting_started/unix-variants.html, not all of the targets are compiled. Can someone provide resources which would ...

C++: xstring vs cstring vs string vs wstring

What are the differences between: #include <xstring> #include <cstring> #include <string> #include <wstring> ? (anymore? lol) ...

How do I get CPU Clock Speed in C++ (Linux)?

How can I get the CPU clock speed in C++? I am running Ubuntu 9.10 if that makes any difference. ...

How to debug a segmentation fault while the gdb stack trace is full of '??' ?

My executable contains symbol table. But it seems that the stack trace is overwrited. How to get more information out of that core please? For instance, is there a way to inspect the heap ? See the objects instances populating the heap to get some clues. Whatever, any idea is appreciated. ...

Replacing special characters from HTML source

I'm new to HTML coding and I know HTML has some reserved characters for its use and it also displays some characters by their character code. For example -: Œ is &#140; © is &copy; ® is &reg; I have the HTML source in std::string. how can i decipher them into their actual form and replace from std::string? is there any libra...

Is filling memory with non zero values slower than filling it with zeros?

I'm not very expert on how processors work, but one might imagine that it was easier to set chunks of memory to zero than non zero values and so it may be marginally faster. ...

Swapping one widget with another in Qt

What is the best way to "swap" one QGraphicsWidget with another in an existing view? I have a tree view widget and a label widget, and I want them to occupy the same space at different times. Specifically, when there's an error, I want to show it in the label, and when there's no error, I want to show the tree. I have tried programmatic...

Convert seconds to Days, Minutes and Seconds.

Hey everyone. I've continuing to learn C++ and I've been set the 'challenge' of converting seconds to format as the Days,Minutes and Seconds. For example: 31600000 = 365 days, 46 minutes, 40 seconds. using namespace std; const int hours_in_day = 24; const int mins_in_hour = 60; const int secs_to_min = 60; long input_seconds; cin >> in...

Vim, C++, look up member function

I am using vim 7.x I am using alternate file. I have a mapping of *.hpp <--> *.cpp Suppose I'm in class Foo { void some_me#mber_func(); // # = my cursor } in Foo.hpp is there a way to tell vim to do the following: Grab word under # (easy, expand("") Look up the class I'm inside of ("Foo") <-- I have no idea how to do this Ap...

C/C++ macro/template blackmagic to generate unique name.

Macros are fine. Templates are fine. Pretty much whatever it works is fine. The example is OpenGL; but the technique is C++ specific and relies on no knowledge of OpenGL. Precise problem: I want an expression E; where I do not have to specify a unique name; such that a constructor is called where E is defined, and a destructor is call...

STL namespace problem in Netbeans 6.8 on AIX

I'm trying to use NetBeans 6.8 on an AIX OS for C++ development. I continue getting an error message for: using namespace std; even after adding the includes for the STL via options -- c/c++ -- code assistance The error says: "Unable to resolve identifier std" Is this a bug in the Netbeans 6.8 AIX version? Or am I missing som...

Can nullptr be emulated in gcc?

I saw that nullptr was implemented in Visual Studio 2010. I like the concept and want to start using it as soon as possible; however GCC does not support it yet. My code needs to run on both (but doesn't have to compile with other compilers). Is there a way to "emulate" it? Something like: #define nullptr NULL (but obviously that wou...

When did "and" become an operator in C++

I have some code that looks like: static const std::string and(" AND "); This causes an error in g++ like so: Row.cpp:140: error: expected unqualified-id before '&&' token so after cursing the fool that defined "and" as &&, I added #ifdef and #undef and #endif and now I get Row.cpp:9:8: error: "and" cannot be used as a macro n...

Java or C++ for my particular agent-based model (ABM)?

...