c++

Grayscale blending with OpenGL?

Is there a way to set the blending parameters so the whole scene renders in grayscale? (without using GLSL, only pipeline functions) Thanks ...

Cleanly duplicate an instance of a baseclass or subclass in C++?

In the trivial example inheritance hierarchy: class Food { virtual ~Food(); }; class Fruit : public Food { virtual ~Fruit(); }; class Apple: public Fruit { virtual ~Apple(); } class Vegetable: public Food { virtual ~Vegetable(); } I wish to create a method that can clone an object from its subclass or baseclass inst...

OOP, assigment operator does not work

Hi! This is from my code: struct R3 { float x; float y; float z; R3(float, float, float); R3(); }; R3::R3(float a, float b, float c) { x = a; y = b; z = c; } R3::R3() { x = 0; y = 0; z = 0; } struct Bodies { int Mass; float Dist[100]; ...

Why is this giving me a segfault?

This: bool grid[1280][1024]; for (int x = 0; x<1280; x++) { for (int y = 0; y<1024; y++) { grid[x][y] = false; } } works fine, but bool grid[1280][1024]; bool grid2[1280][1024]; for (int x = 0; x<1280; x++) { for (int y = 0; y<1024; y++) { grid[x][y] = false; grid2[x][y] = false; } } ...

how to reverse engineer c++ project?

as asked above. cheers in advance ...

What is the best way to represent tree structure in memory as a cache?

Hello all I have tree with nodes. The nodes are constructed by TCP API request response value. To make less requests I'd like to represent the tree in a cache structure, that each time when TCP request are about to be invoked it will check the cache first. What is the best way to do it? I mean the tree cache part, in my case I'm using Qt...

Crazy idea: Identify if system is idle when it's a black box

I need to be able to tell if a series of servers have anyone active on them, and if not then to automatically shut them down (turn off the VM). It's not a trivial task, because I have 1000+ server instances that include an assortment of OSes (Win, Unix, Linux) and many different type of configurations. This makes installing an uptime age...

randomise a two-dimensional array with chars?

Is this code a good solution to randomise a two-dimensional array and write out all the symbols on the screen? If you have a better tip or solution please tell me. int slumpnr; srand( time(0) ); char game[3][3] = {{'O','X','A'}, {'X','A','X'}, {'A','O','O'}}; for(int i = 0 ; i < 5 ; i++) { slumpnr = rand()%3; if(slumpnr == 1) ...

Class variable within its definition?

This is probably a dumb question. I am trying to make a text-mud. I need each Room class to contain other Room classes that one can refer to when trying to move to them or get information from them. However, I can not do that because I obviously can not declare a class within its definition. So, how do I do this? Here's what I mean when ...

what video/image encoding format is recommended when trying to encode and transmit raw video in real time ?

Hi, I'm trying to encode and transfer raw video frames over LAN (100 Mbps) connection (frames captured by a web cam). What video/image encoding format is recommended for fast compression (with not much regard for the compression ratio) ? Thanks, ...

QT: How to open several windows (QWidgets) at once?

Hello! I'm doing web interface testing program which should open two urls in two webkit windows simultaneously. I already did the code for the test automation. 1) User pushes 'Go' button and webkit (QWidget) window opens 2) TestBot class object performs tests 3) Closes Now my question: After clicking on the button 'Go', how do I op...

Check for null pointer

Hi, I'm building a iphone app and using c++ and am having trouble checking if a pointer is null. IMyInterface* myInterface; if ( !myInterface ){ //doesn't work myInterfacee->doSometing(); } if ( myInterface != 0 ) { //doesn't work myInterfacee->doSometing(); } if ( myInterface !...

C++ Classes with android

The android NDK supports c++, but does it support c++ classes?? If so can you give a simple example and the steps needed to implement the class with the java source. ...

C++ Failing at SOCKET accept() Method

Hey guys, I am currently make a Server, I learned to make something like this: while(true) { SOCKET s = accept(s, ....) // do something with the connection printf("connection\n"); } I learned that it will stuck at accept(..) while there isnt a connection. In my Program there isnt any connection yet, but it get overflo...

C++ template specialization

Hello! Does someone know a way to achieve or emulate the following behaviour? (this code results in compilation-time error). E.g, I want to add specific template specialization only in derived classes. struct Base { template <typename T> void Method(T a) { T b; } template <> void Method<int>(int a) { float c; }...

for-loop to compare the two-dimensional array???Help!!

I am currently developing a game in which a player plays slot machine.The game is based on that the user stops in money, 100sek, 300sek or 500sek. Then the user makes a bet for each game. The one-armed bandit randomly spits out 3 different symbols in nine pieces fields. See figure: The goal of the game is to obtain as many rows, column...

is there a simple command-line command in linux to justify C++ code?

Possible Duplicate: Best C++ Code Formatter/Beautifier is there a simple command-line command in linux to justify C++ code? I could use an editor, maybe, but I would rather just have some command that spits out indented justified code. ...

c++ metaprogramming madness

consider the following templated datastructures enum eContent{ EINT = 1, EFLOAT = 2, EBOOL = 4 }; template<int> struct Container{ Container(){assert(false);} //woops, don't do that! }; template<> struct Container<EINT>{ Container():i(123){} int i; }; template<> struct Container<EFLOAT>{ Container():f(123.4...

insert to sorted position linked list

Hello, I have question quite much related to this one I asked a while ago http://stackoverflow.com/questions/3743764/place-a-value-in-the-sorted-position-immediately I wonder if you can use the same approach in that you step backward in a linked list to find the position it should be inserted into. If it is possible how do you loop a ...

Python Swig wrapper: how access underlying PyObject

I've got class A wrapped with method foo implemented using %extend: class A { ... %extend { void foo() { self->foo_impl(); } } Now I want to increase ref count to an A inside foo_impl, but I only got A* (as self). Question: how can I write/wrap function foo, so that I have an access both to A* and underlying PyObject*...