c++

Set up CUTE (Eclipse CDT Unit Testing Plugin) on OSX

I am trying to set up the CUTE unit testing plugin for Eclipse C/C++ Development Tools. The documentation says: If you did not install Boost in the standard location, you will need to specify it. Right click on the newly created CUTE project, and select Properties. In C/C++ Build, Settings, choose the Tool Settings tab. Specify the ...

Draw a antialiased line in a fast way.

I have a little problem. I've recently created an algorithm to allow thick lines to be drawed onscreen (as a quad structure), the problem is that when the line is very long and diagonal the aliasing is very high, making the line look very bad. What are my chance to reduce the aliasing while trying to have high performance? I'm using (as...

C++ TCL (tree container library): How to traverse a tree from a node straight to root

I am using this library to hold information about tree structure: http://www.datasoftsolutions.net/tree_container_library/overview.php Here is simplified version of my C++ code: #include "tcl/sequential_tree.h" // Node has some data which is not important now typedef sequential_tree<Node> gametree_t; typedef sequential_tree<Node>::i...

unresolved external symbol "public: void __thiscall..."

I'm using boost::function to enable the passing of a function to a Button constructor so it holds that function. Calling it whenever it is activated. typedef boost::function< void() > Action; In my TitleState I've constructed a Button like this. m_play( ButtonAction, // This is where I pass a function to Button's Action argume...

OpenGL Texture Transparency

I'm using C++ and OpenGL to make a basic 2D game, I have a png image with transparent areas for my player. It works perfectly on my laptop and lab computers, but on my desktop the entire image is mostly see through, not just the areas that are meant to be. What could cause/fix this? Here is the code I've used and is the same on all mach...

C++ STL list vs set

Hi, what of those two is faster for random insertions and deletions? I guess list, having the values as the keys as it is with sets seems to be attractive too though. Is performance similar for iterating over the whole container? Thanks! ...

Problem with method in a class when called from another class

Hi, I'm writing a simple scene graph to hold some objects so I can control the rendering and drawing of these objects in OpenGL. I have two classes, one called GameObject which defines the objects with certain parameters such as position and velocity as well as how to draw the object. It has a method called update() which is used to ca...

Memory debugger for mixed-mode C++ applications

I have to maintain a large C++ mixed-mode application (VC++ 2005, CLR-support: /clr:oldsyntax). I suspect the program has a number of memory leaks but it's hard to find them manually. For native C++ applications we use Purify (and Valgrind on Linux). Unfortunately Purify does not support mixed mode assemblies. Anybody here knows a dece...

VS C++ 2008: Modifying Output text?

I'm using Visual Studio C++ 2008 Express Edition. Is it possible to modify the text in the Output pane for compilation (or other) errors? For example, I might receive an error that reads: error C2556: int Class::getResult(void) + a lot more relative garbage. I can parse the output text and find and fix my mistakes easily. It would st...

How to implement " char * ftoa(float num) " without sprintf() library function in C, C++ and JAVA?

Today I appeared for an interview, and the question was writing my own "char * ftoa(float num) " in C, C++ and Java. Yes, I know float numbers follow IEEE standard while allocating their memory, but I don't know float to char conversion by using Mantissa and Exponent in C. I don't have any idea to solve the above problem in C++ and J...

Initialize static member of template inner class

I have problem with the syntax needed to initialize a static member in a class template. Here is the code (I tried to reduce it as much as I could): template <typename T> struct A { template <typename T1> struct B { static T1 b; }; B<T> b; typedef B<T> BT; T val() { return b.b; } }; template <typename T> T A<T>::BT::...

Byte to bit convertion in visual c++ 2008 express edition

i am new user of vc++.so here i want to convert a byte array having a size 8000000.i want to convert that byte array in to bit and display it using some control in form like picturebox..i tried .save method but it dint work...so can someone give any idea about it with code??? ...

Assignment vs Initialization in C++

I thought that constructors control initialization and operator= functions control assignment in C++. So why does this code work? #include <iostream> #include <cmath> using namespace std; class Deg { public: Deg() {} Deg(int a) : d(a) {} void operator()(double a) { cout << pow(a,d...

const correctness and return values - C++

Please consider the following code. struct foo { }; template<typename T> class test { public: test() {} const T& value() const { return f; } private: T f; }; int main() { const test<foo*> t; foo* f = t.value(); return 0; } t is a const variable and value() is a constant member-function...

What is causing a segmentation fault?

I have been attempting to write a program that will determine if a number is prime or not. I have based it off of the Sieve of Eratosthenes. Anyway, my program works for small numbers (15485863 works), but if I use large numbers (ex. 17485863) I receive a segmentation fault. I am using unsigned long longs and do not think I have surpasse...

Undefined reference to...

Hi, I'm doing an opengl/qt3 assignment, but I'm running into an undefined reference error: Renderer.h: ... #include "Mesh.h" ... Mesh mesh; Renderer.cpp: ... mesh.load("ball.obj"); ... Mesh.h: ... bool load(string filename); ... Mesh.cpp: #include "Mesh.h" ... bool Mesh::load(string filename) { ... } ... but the compiler complain...

Qt - how to detect what application is in focus

Is it possible to know what application is in focus using Qt ? ...

C++ Unwanted infinite while loop

I get an infinite loop when I use the following code in C++ and I don't understand why. I suspect the problem is within the input_words() function. Here is the code: #include<iostream> using namespace std; string input_words(int maxWords) { int nWord = 0; string words[maxWords]; string aWord = ""; while (aWord != "Quit"...

How to declare vectors in C++ ?

Hi, I'm trying to use a vector of strings in my code instead of an array of strings but apparently I miss some detail in the declaration of the vector. Using the following code, I get this error: ‘vector’ was not declared in this scope // Try to implement a vector of string elements #include<iostream> using namespace std; int main() ...

Limit Speed Of Gameplay On Different Computers

I'm creating a 2D game using OpenGL and C++. I want it so that the game runs at the same speed on different computers, At the moment my game runs faster on my desktop than my laptop (i.e. my player moves faster on my desktop) I was told about QueryPerformanceCounter() but I don't know how to use this. how do I use that or is there a b...