c++

Custom manipulator for C++ iostream

Hi, I'd like to implement a custom manipulator for ostream to do some manipulation on the next item being inserted into the stream. For example, let's say I have a custom manipulator quote: std::ostringstream os; std::string name("Joe"); os << "SELECT * FROM customers WHERE name = " << quote << name; The manipulator quote will quote n...

Any nice place to communicate with c++/game developers?

Hi I'm a game programmer working in Korea I started Stackoverflow recently and I found it help me a lot. also I think communicating with other developers is good way to learnand improve myself but the Stackoverflow is the only site I know to communicate (especially in English). Any other nice place to communicate(ask/answer/talk) with ga...

Implementing a C++ threading Library in c++

I am a java programmer but currently working on the c++ language. Unlike java, the c++ does not define any threading utility. It is a little hard for me to implement a multi-threaded application in c++. Is there anyway someone can implement his own threading library using c++? Must you be able to grasp some concept of assembly language? ...

Passing a variable of type int[5][5] to a function that requires int**

I'd like to test a function that takes runtime-allocated multidimensional arrays, by passing it a hardcoded array. The function has a signature of void generate_all_paths(int** maze, int size) and the array is defined as int arr[5][5] = {REMOVED}. I'm not exactly sure how to properly coerce the array for the function (or if that is imp...

How do you make sense of the error: cannot convert from 'int []' to 'int []'

When compiling the following code: void DoSomething(int Numbers[]) { int SomeArray[] = Numbers; } the VS2005 compiler complains with the error C2440: 'initializing' : cannot convert from 'int []' to 'int []' I understand that really it's trying to cast a pointer to an array which is not going to work. But how do you explain the ...

Unicode Basics on Windows

Hello, I have a C++ library which I deliver to other developers. One of them needs i18n, so he asked me if I could add L prefix to the strings in the API. I don't know much about i18n so I have some basic questions: When I compile my lib with Unicode, can other developers use this build as usual ? Or shall developers also change the...

C++ string parsing (python style)

I love how in python I can do something like: points = [] for line in open("data.txt"): a,b,c = map(float, line.split(',')) points += [(a,b,c)] Basically it's reading a list of lines where each one represents a point in 3D space, the point is represented as three numbers separated by commas How can this be done in C++ without...

Why won't my OpenGL draw anything?

I'm working on porting my open source particle engine test from SDL to SDL + OpenGL. I've managed to get it compiling, and running, but the screen stays black no matter what I do. main.cpp: #include "glengine.h" int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { //Creat...

C++ slicing in Java / C#

Can C++ slicing apply to other languages too, like Java/C#? ...

AddRef and function signature

I've always used the following rule for signatures of functions that return ref-counted objects based on whether they do an AddRef or not, but want to explain it to my colleagues too... So my question is, is the rule described below a widely followed rule? I'm looking for pointers to (for example) coding rules that advocate this style. ...

Texturing Spheres with Cubemaps (not reflection maps)

I want to texture a sphere with a cube map. So far my research has thrown up many many results on Google involving making OpenGL auto generate texture coordinates, but I want to generate my own coordinates. Given an array of coordinates comprising the vertexes of an imperfect sphere (height mapped but essentially a sphere) centered on 0...

Is modern C++ becoming more prevalent?

When I first learned C++ 6-7 years ago, what I learned was basically "C with Classes". std::vector was definitely an advanced topic, something you could learn about if you really wanted to. And there was certainly no one telling me that destructors could be harnessed to help manage memory. Today, everywhere I look I see RAII and SFINAE ...

Factory object vs factory function

I have an ABC with several derived classes. To create these derived classes I use the factory pattern: .h file: class derivedFactory { public: base* createInstance(); }; .cpp file: base* derivedFactory::createInstance() { new derived(); } Is there any advantage to this over just having a free function: .h file: base* de...

I have VS C++ Express. Is there a way to create .DEF files?

I would be extremely appreciative if anybody can help me. I am learning C++ and I have been trying figure this one out. Basically, VS C++ Express does not come with the .DEF template. What other way can I go about creating this file? Is there a parameter I can set in VS so that the linker can create this on the fly? Thanks!!! ...

With this technology, would it be possible to compile and run silverlight IL in Flash?

I don't really understand this article. But it sounds like you can compile C/C++ for flash. If that's possible, how hard would it be to compile and run Mono inside flash? Sounds stupid I know...maybe I'm going crazy with my age. ...

libstdc++ 64bit and 32bit version on the same machine

Hello All I am trying to cross compile a version of my software for a 64bit platform. Can I have the 32bit and 64bit version of libstdc++ installed on the same machine without too much worries of breaking my linux install. The Os is 32bit ubuntu. I have not cross compiled before and just wanted to check that if I set my CFLAGS and LDFL...

Is it best practice to use COM properties or COM setters and getters in C++?

I am relatively new to development within COM, and I was wondering what the community standard was for access of COM object properties. I have seen both of the following conventions in code: comObjectPtr->PutValue(value); and comObjectPtr->Value = value; and both seem to work, but I was wondering if there was an inherent advantage ...

Binary literals?

In code, I sometimes see people specify constants in hex format like this: const int has_nukes = 0x0001; const int has_bio_weapons = 0x0002; const int has_chem_weapons = 0x0004; // ... int arsenal = has_nukes | has_bio_weapons | has_chem_weapons; // all of them if(arsenal &= has_bio_weapons){ std::cout << "BIO!!" } But it do...

Which sector of software industry uses C++?

Like most people, I learnt C++ after C. I learnt C++ because it was one of those languages which fetched jobs. I am still studying (doing masters) though. One of my cousins has been working as a developer for around 12 years. He advises me to learn Java so that I can land up in a good job. He says only few sectors like tele communicatio...

What's a good HTML template engine for C++?

Planning to write a website in C++. Would like to use a template system like Clearsilver, but maybe there's a better alternative? ...