c++

C++ : How to include boost library header in VC++6?

I used this guide to rebuild the boost library in VC++6 under windows XP. But is having problems trying to include the header files. By default, the boost library makes use of point 1 as follows to declare the header files. But if I used point 1, I get "fatal error C1083: Cannot open include file...". I tried using point 2 to declare and...

Recommendation for C++ wrapper for cross platform dynamic library bindings (basically a lightweight, high performance COM or CORBA) (only in-proc is necessary)

We're developing an application that will have a plug-in "architecture" to allow consumers of the app to provide their own proprietary algorithms. (We will basically have a set of parsers and allow third parties to provide their own as well) The domain space requires very high performance, so out-of-process bindings are not going to wo...

Which graph implementation is best?

I'm writing code for a graph. Which is better for implementing a digraph with weighted edges? set 1 class Node ; class Edge { Node *src, *dst ; int cost ; } ; class Node { list<Edge> edges ; // slightly redundant. // because an edge connects two nodes, // the information in each Edge's src // is redundant to this } ; s...

Method not being called in switch statement

Edit: Works perfectly in debugger now, but block doesn't rotate at all when run normally.. I'm having a problem that I've run through the debugger a ton and have narrowed it down to this. I've got a block on screen that comes down in the middle and rotates. The image of the block obviously changes depends on the rotation, and this is d...

Compiling SDL on OS X with makefile

I'm trying to compile the tetris program I wrote with C++ and SDL on OS X. First I tried doing this: `g++ -o tetris main.cpp `sdl-config --cflags --libs` -framework Cocoa` and got this: Undefined symbols: "Game::startGame()", referenced from: _main in ccQMhbGx.o "Game::Game()", referenced from: _main in ccQMhbGx.o ld:...

Is string::compare reliable to determine alphabetical order?

Simply put, if the input is always in the same case (here, lower case), and if the characters are always ASCII, can one use string::compare to determine reliably the alphabetical order of two strings? Thus, with stringA.compare(stringB) if the result is 0, they are the same, if it is negative, stringA comes before stringB alphabetically...

glBitmap() without GL_COLOR_INDEX

Is it somehow possible to get glBitmap() to draw a GL_RGBA bitmap? glBitmap() is a lot quicker than glDrawPixels(), but perhaps that has to do with that the format is GL_COLOR_INDEX instead of GL_RGBA? I'm running my glDrawPixels() in a display list; is there perhaps some smart way to speed it up? ...

How to get the x,y coordinate of a mouse-click with win32 C++ on a directx object?

How can I get the x,y coordinate of a mouse click, to see if it is over my menu button drawn by directx? Currently, my codebase has the following mouse-related class that doesn't seem to be able to give me this..I'm not sure how this might work. InputMouse::InputMouse() : m_LastX(-1), m_LastY(-1) { m_MouseActionEvent.clear(...

How to check a Graph if a Planar Graph or not?

I'm learning about the Planar Graph and coloring in c++. But i don't know install the algorithm to do this work. Someone please help me? Here i have some information for you! This is my code! And it still has a function does not finish. If someone know what is a "Planar Graph", please fix the Planar_Graph function below! :D thanks so mu...

overloading new and delete problem

Hi! I try to follow this article: http://flipcode.com/archives/How%5FTo%5FFind%5FMemory%5FLeaks.shtml to overload my new and delete functions in order to track memory leaks. however - if i try to compile, I get a C2365: "operator new": redefinition; previous definition was a "function" in the file xdebug xdebug gets included in xlo...

How to write a GUI wrapper around a command line program in *C*?

System(); is able to call a program in PATH. How is it possible to send stdin read from e.g. a text field on a GUI to a command line program such as ftp, sftp ... with their own prompts? System() waits for a program to quit, but ftp does not without user interaction. It's also not possible to create a batch file since it's read only one ...

cos returns wrong values?

I have a strange problem with the standard cos function of cmath/math.h. Apparently under some circumstances it returns a wrong or simply undefined value. #include <cmath> #include <iostream> int main() { double foo = 8.0 * 0.19634955; // 1.5707964 double bla = std::cos(foo); // should be 0.9996242168245 std::cout << bla << std::...

maximum value of int

is there any code to find the maximum value of integer (which is acccording to the compiler) in c/c++ like Integer.MaxValue function in java ...

antlr : C++ target with visual studio 2008

the Antlr site is not clear on the subject of compiling a grammar for C++, it says that the tool will generate C code compatible with C++, what dose it mean? will I be able to compile this code with VS 2008 ? ...

How to properly initialize class value member?

Hello, lets say we have this: class Foo { public: Foo(const Bar& b) : m_bar(b) {} private: Bar m_bar; }; Now regarding efficiency C++ FAQ LITE says this: Consider the following constructor that initializes member object "x" using an initialization list: Fred::Fred() : x(whatever) { }. The most common benefit of d...

Network protocol object serialization in C++

Hello, I'm writing some C++ code that will have to send data over TCP/IP. I want this code to be portable on Linux/Windows/Osx. Now, as it is the first time I write portable network code, I basically need some simple functions to add to certain objects like: class myclass{ ...member... public: string serialize(){ std::ostringst...

C++ binary file I/O to/from containers (other than char *) using STL algorithms

I'm attempting a simple test of binary file I/O using the STL copy algorithm to copy data to/from containers and a binary file. See below: 1 #include <iostream> 2 #include <iterator> 3 #include <fstream> 4 #include <vector> 5 #include <algorithm> 6 7 using namespace std; 8 9 typedef std::ostream_iterator<double> oi_t; 10 typed...

Assigning a "const char*" to std::string is allowed, but assigning to std::wstring doesn't compile. Why?

I assumed that std::wstring and std::string both provide more or less the same interface. So I tried to enable unicode capabilities for our application # ifdef APP_USE_UNICODE typedef std::wstring AppStringType; # else typedef std::string AppStringType; # endif However that gives me a lot of compile errors when -DAPP_USE_UNI...

Avoid slicing of exception types (C++)

I am designing an exception hierarchy in C++ for my library. The "hierarchy" is 4 classes derived from std::runtime_error. I would like to avoid the slicing problem for the exception classes so made the copy constructors protected. But apparently gcc requires to call the copy constructor when throwing instances of them, so complains abou...

Curving from one point to another

I have tiles that are in random spots, and they wind up at x',y' (to make a nice 2d array) by doing : Xt = (((X-X)/T)*t)+X , Yt = (((Y-Y)/T)*t)+Y This works well, but it is linear. I'm looking for something curvier. A little bit like a parabola works. Basically instead of getting to X' in a straight line, I'm looking for an algor...