c++

How can you force recompilation of a single file in a Makefile?

The idea is that a project has a single file with __DATE__ and __TIME__ in it. It might be cool to have it recompiled without explicitly changing its modification date. edit: $(shell touch -c ..) might be a good solution if only clumsy. ...

Please Solve/Answer C++ Program problems with Functions Variables

Please solve/answer problems to get program to work. I am not fully understanding the passing variables by reference or value and I think that is what is making this so hard. So if you could fix the program. I've been at this for the last 2 days. I have included my full code. paxdiablo suggested this and I'm trying to do what they said ...

Is order of iteration for Qt’s QHash repeatable across multiple identical runs of a program?

Assume that a program is run several times in identical fashion. In each run, the same set of objects is insert into a QHash in the same insertion order; then the objects in the QHash are iterated. The question is will the objects be iterated in the same order in each run of the program? ...

Replacement of random string/char array characters using match ups.

while (1) { char j; if (x[j] == y[j]) Here I am trying to start a loop where I want to able to match any of the characters from char array 'x' with char array 'y'. If the characters do match from x to y then I want to keep them as they are and if they don't I want to be able to replace them with a star '*'. (e.i. x = [a,p,f] an...

What is an inner miter calculation?

I found the following algorithm to generate polygon outlines: void CGlShape::GenerateLinePoly(std::vector<DOUBLEPOINT> &input, int width) { OutlineVec.clear(); if(input.size() < 2) { return; } if(connected) { input.push_back(input[0]); input.push_back(input[1]); } float w = width / 2.0f; //glBegin(GL_TRIANGLES); for...

Linux C++: Does a return from main() cause a multithreaded app to terminate?

This question seems like it's probably a duplicate, but I was unable to find one. If I missed a previous question, apologies. In Java, where I have most of my experience, if your main() forks a thread and immediately returns the process continues to run until all (non-daemon) threads in the process have stopped. In C++, this appears no...

C++ Functions and Passing Variables

Possible Duplicate: C++ passing variables in from one Function to the Next. The Program is working but when it comes to getUserData it asks for the same information 4 times and then displays the results with negative numbers. I used test numbers for number of rooms 1, 110 for sqrt feet in the room, 15.00 for cost of paint. /...

Does std::move result in slicing?

For example, in unique_ptr<Derived> = new deriv; std::vector<unique_ptr<Base>>.push_back(std::move(deriv)); will deriv be sliced to type unique_ptr<Base>? ...

C++ arithmetic operations in floating point

Is there a way in C++ to have it evaluate each floating point operation as a double even if the arguments are int? I have a program and numerous places I have code such as 1/2, 5/6. In these cases C++ casts the result to an int, that screws up the whole calculation. From the perspective of financial computations, are there other librarie...

Practical Books on game development in C++?

Is there some books that teaches the game structure: How to create UI, menu, game flow (for e.g. What happen when you proceed to next phase of the game? What are the changes to the main loop?) and also I would like the books that really show a working complete game code/structure with explanation, because most of the books I found co...

shared_ptr and slicing

Hi Someone I worked with once said that shared_ptr was unsafe and would slice when casting from a derived class to a base class (i.e. upcasting). For example if there were 2 classes A and B where B derived from A, then shared_ptr<A> a(new B) would slice. I pointed him to http://www.boost.org/doc/libs/1_43_0/libs/smart_ptr/shared_ptr...

C++ shared_ptr - attach to a new raw pointer?

I think I'm missing something simple here. I'm using Boost's shared_ptr. shared_ptr<Foo> pA(new Foo()); shared_ptr<Foo> pB(new Foo()); Now, I want to switch pB so it contains the contents of pA, decrementing the ref count of pB. How can I do this? ...

Using template for return value. how to handle void return?

Hello all, I have structure for storing callback function like this: template<class T> struct CommandGlobal : CommandBase { typedef boost::function<T ()> Command; Command comm; virtual T Execute() const { if(comm) return comm(); return NULL; } }; Seems like it should work fine except w...

What is the difference between C++ class vs structure.

Possible Duplicate: What are the differences between struct and class in C++ I have come across this question many time in interview but could not answered properly. two difference I know is default access specifier(public in struct & private in class ) memory layout of class is unpredictable when multiple section like priv...

C++ template meta-programming kung-fu challenge (replacing a macro function definition)

Situation I want to implement the Composite pattern: class Animal { public: virtual void Run() = 0; virtual void Eat(const std::string & food) = 0; virtual ~Animal(){} }; class Human : public Animal { public: void Run(){ std::cout << "Hey Guys I'm Running!" << std::endl; } void Eat(const std::string & food) { ...

How I can get ports assosiated to aplication that oppened them?

Hello all I need to get a list of all opened ports on my machine and what application opened them . I need to get this information programmatically. Thanks. ...

Any benefits of learning 3d software rasterization & theory before jumping into OpenGL/Direct3D?

I came across a very interesting book. I have done some 2d games but 3D is a whole new ballpark for me. I just need to know if there any benefits of learning 3d software rasterization & theory before jumping into OpenGL/Direct3D? Any reason why to either approach? Thanks in advanced! ...

How to be notified of any update from Dynamic Data Exchange (DDE) ?

Hello, I was following the example from How to use Dynamic Data Exchange (DDE) with Word and Excel from Visual C++ and I somehow managed to able able to retrieve the value from the Excel. Now the question is, with this example, I have to run the application over again to get the necessary update. How do I make it in such a way that if ...

Does VC++ support _mm_malloc ?

Does Visual Studio C++ 2008/2010 support _mm_malloc officially? It is defined in malloc.h but I can't find its description in the MSDN library. ...

Infernal Libraries (aka DLL Hell)

In a Project of mine, I use a Delphi Application which dynamically loads a wrapper DLL (exporting C-Style functions) which in turn is statically link against a bunch of 3rd party DLLs. It works fine on my test machines, but on my customers computer it failed to initialize with an error Message like "Couldn't find entrypoint _somefunctio...