c++

C++ - design question

Hello! I am working on game engine prototype and have the following question: Right now my engine implementation is DirectX-bound and everything works fine. I've got a core::Renderer class which has methods to render geometry, set shaders, lightning, etc... Some of them are templated, some not. class Renderer { // ... templat...

C++ Data structures API Questions

What C++ library provides Data structures API that match the ones provided by java.util.* as much as possible. Specifically, I am looking for the following DS and following Utility Functions:- **DS**: Priority Queue, HashMap, TreeMap, HashSet, TreeSet, ArrayList, String most importantly. **Utility**: Arrays.* , Collections.*, Rege...

Is it bad practice to have an application which ships with lots of DLL's?

Is it better to have lots of DLL dependencies or better to static link as mich as possible? Thanks ...

Data structure for matching sets

I have an application where I have a number of sets. A set might be {4, 7, 12, 18} unique numbers and all less than 50. I then have several data items: 1 {1, 2, 4, 7, 8, 12, 18, 23, 29} 2 {3, 4, 6, 7, 15, 23, 34, 38} 3 {4, 7, 12, 18} 4 {1, 4, 7, 12, 13, 14, 15, 16, 17, 18} 5 {2, 4, 6, 7, 13, 15} Data items 1, 3 and 4 match the set beca...

Convert a dll to a lib for static linking?

Is there a free way to statically link a dll? I've tried dll to lib but $999 is too expensive. What are alternatives since I want to have 1 nice exe instead of 1 exe + 1 DLL. Thanks ...

how to use stl::map as two dimension array

Could you let us know how to use stl:map as two dimension array? I wanted to access the individual elements as like mymap[i][j] where I do not know beforehand what the value of i or j could be. Any better ideas to do the same thing in other way? ...

Cross platform hardware accelerated 2d C++ app?

I know a decent amount of C++, and now I wanted to explore making a game. I was wondering what the best approach would be in terms of writing a hardware accelerated game that's still cross-platform (Windows/OSX/Linux). It's going to be a 2d game, but intensive enough that a CPU renderer probably wouldn't cut it. I know there's OpenGL, b...

singleton class

Possible Duplicates: Singletons: good design or a crutch? Problems with Singleton Pattern Singleton: How should it be used Hi.. Please help me up to understand what is the use of singleton class Thank you ...

strftime/strptime problem

I've written a function to convert datetimes from one format to another - int convertDateTime(char* source_fmt,char* dest_fmt,char* source,char* dest) { struct tm tmpptr; if (strptime(source,source_fmt, return -1; } strftime(dest,100,dest_fmt, return 0; } It works fine for most...

c++ programs developed and compiled with visual studio

I have Visual c++ 2010 express installed. I develop some apps with it (mainly console based for now). I usually compile via the cl.exe command line option. Does these apps that I compiled with Visual C++ require .net framework to run? Also what exactly is the object code file? Lastly, I know that mono has Windows Form 2.0 fully imple...

Swap arrays by using pointers in C++

I have two arrays of pointers to doubles that I need to swap. Rather than just copy the data within the arrays, it would be more efficient just to swap the pointers to the arrays. I was always under the impression that array names were essentially just pointers, but the following code receives a compiler error: double left[] = {1,2,3}; ...

C++ book for experience C# developer

I'm experience C# developer and I decide to learn C++ programming language. I've reading The Definitive C++ Book Guide and List and I'm much interesting these two books C++ Primer and Programming: Principles and Practice Using C++. I want to know between these books, which one is suitable for me? ...

QT Creator compile C++ file? Very simple question

#include <iostream> using namespace std; int main () { cout << "Hello World!"; return 0; } This code works, but it run then close windows immediately. Need a fix :) ...

How not to wait for other threads in OpenMP?

Hi I am considering using OpenMP for multithreading in C++. But I wonder if there is a way tell a thread not to wait for other concurrent thread and continue with my program? (Maybe I can cancel/kill other threads?) I am aware of the existence of "nowait" clause, but I want the decision of "wait" or "not to wait" to be done dynamically...

How do I specify default argument values for a C++ constructor?

Hi, I have a constructor declaration as: MyConstuctor(int inDenominator, int inNumerator); and definition as MyConstuctor::MyConstuctor(int inDenominator, int inNumerator, int inWholeNumber = 0) { mNum = inNumerator; mDen = inDenominator; mWhole = inWholeNumber; } but i want to have an option of passing whole numbe...

Default template parameters

template<class T1, class T2 = int> class A; template<class T1 = int, class T2> class A; which is equal to this? 1) template<class T1 = int, class T2 = int> class A; 2) template<class T1, class T2> class A; I know 1st option is correct. according to the standards But ,for me in various compilers 1st option is not acceptin...

Function template

Hi, I have a function template as this. template<class T> T getFromString(const string& inStream) { istringstream stream (inStream); T t; stream >> t; return t; } I am not getting how to use this function template. I have tried the usual method of using function template it was giving an error. Please let me know for...

Segmentation fault in equating a char pointer value to some char

Possible Duplicate: Why is this C code causing a segmentation fault? char* string = "abcd"; now when i try to change some character of this string i get segmentation fault *string = 'p'; or string[0] = 'p'; string[0] = 52; Can someone please explain me the reason that why is it happening. Thanks Alok.Kr. ...

wxString to UniChar*

How to convert from wxString to UniChar? ...

Weird behavior of right shift operator

Hi, I recently faced a strange behavior using the right-shift operator. The following program: #include <cstdio> #include <cstdlib> #include <iostream> #include <stdint.h> int foo(int a, int b) { return a >> b; } int bar(uint64_t a, int b) { return a >> b; } int main(int argc, char** argv) { std::cout << "foo(1, 32): " <<...