c++

C++ Buildsystem with ability to compile dependencies beforehand

Hi, I'm in the middle of setting up an build environment for a c++ game project. Our main requirement is the ability to build not just our game code, but also its dependencies (Ogre3D, Cegui, boost, etc.). Furthermore we would like to be able build on Linux as well as on Windows as our development team consists of members using differen...

How to mitigate class declaration being far from its owner namespace declaration in a file?

So, I've seen how useful namespaces can be to organize declarations into their respective groups, but now comes an issue with this. The difference between making a library in C and a library in C++ is in C you must prefix your declarations with what they belong to, for example a library we'll dub MyMath might have a vector class, well t...

Can you Hide a virtual method in c++?

I have a base class with a virtual function. virtual CString& Foo(); I want to overload this in subclass like so CString Foo(); is there a way to hide the base classes virtual function? Something like the new keyword in vb.net or C# ...

Storing variable sized strings in structures

I'm reading a file in C++ using streams, specifically, fstream, not ifstream. blah blah blah\n blah blah\n blah blah blah blah \n end This repeats over and over with varble number of blah's in each line, constant number of lines between each end, end is the delimiter here I want to read one set of data, then store it in a characte...

What's the point of g++ -Wreorder?

The g++ -Wall option includes -Wreorder. What this option does is described below. It is not obvious to me why somebody would care (especially enough to turn this on by default in -Wall). -Wreorder (C++ only) Warn when the order of member initializers given in the code does not match the order in which they must be executed. For...

C++ text file pointer problems

I am writing a function which should (if the file already exists) increment the first number by one and append the parameters of the function to the end of the file. Example: append (4,9); append (5,6); File contents at 1: 1 \n 4 \n 9 File contents at 2: 2 \n 4 \n 9 \n 5 \n 6 int append (int obj, int objType) { ifstream infile; ...

What on earth would compell C++ to call this function?

I'm working on a programming language that uses C++ as it's target language for now. I'm hitting an exceptionally strange backtrace. #1 0x08048d09 in factorial (n=0x8052160) at ir.cpp:35 35 shore::builtin__int * __return = NULL; (gdb) bt #0 shore::builtin__int::__mul__ (this=0x8052160, other=0x8052288) at /home/alex/projects/sho...

Fastest socket method for a lot of data between a lot of files

I'm building a socket application that need to shuffle a lot of small/medium sized files, something like 5-100kb sized files to a lot of different clients (sort of like a web server, but still not quite). Should I just go with the standard poll/epoll (linux) or async sockets in winsock (win32), or are there any methods with even more pe...

Using C++ in xcode for image and video processing

I am studying in the area of image and video processing - specifically in the field of pattern recognition (objects, people etc.). I wish to use a programming language to apply the transformation to images and video (more importantly video). I am thinking of using C++ in Xcode to do this. The algorithms I wanna build I want to take data ...

Converting C++ Bit Pattern to Java

I am converting a C++ program to Java and got completely stuck in the following method which blew my mind. Would you be kind enough to explain what this method is doing? long TSBCA::GetSignedValue(const NDataString &value) { static NDataString s; s = value; long multiplier(1); size_t len(s.Len()); ...

Trouble understanding C++ `virtual`

I'm having trouble understanding what the purpose of the virtual keyword in C++. I know C and Java very well but I'm new to C++ From wikipedia In object-oriented programming, a virtual function or virtual method is a function or method whose behavior can be overridden within an inheriting class by a function with the same ...

C++ -- Pointers to Arrays -- Arrays of Pointers

Hello, I notice this has caused confusion for several people, but after reading a couple of posts on here and the cplusplus tutorial my brain is still scrambled. Suppose I have the following variables in a header file - int numberOfLinePoints; D3DXVECTOR3* line; //confused as to what it is Then in the implementation C++ file I ini...

Proper layout of a C++ header file

What is the proper layout of a C++ .h file? What I mean is header guard, includes, typedefs, enums, structs, function declarations, class definitions, classes, templates, etc, etc I am porting an old code base that is over 10 years old and moving to a modern compiler from Codewarrior 8 is proving interesting as things seem all over th...

common errors and fixes in C++

Does anyone have a site that teaches how to fix common compiler errors for newbies? Like does not name a type, etc? ...

How Does PHP's main.c Start Execution

I was poking around the PHP 5.3.1 source tree, and decided to take a look at main.c. I was curious what was happening behind the scenes whenever PHP runs. I was under the impression that any C or C++ program starts execution in a function named main, but I don't see a function with that name in main.c. Where does PHP code actually sta...

How can I use a custom type for keys in a boost::unordered_map?

I'm using Boost's implementation of a hash map in a project right now, and I'm trying to implement a custom type for keys. I have four unsigned integers which I'd like to combine into a single 128-bit datatype to use as a key. I've created a struct with a 32-bit integer array of four elements, which serves as my storage. To be honest, I...

Lightweight debugging on embedded Linux

I'm developing an application that runs on a small Linux-based SBC (~32MB RAM). Sadly, my app recently became too large to run under GDB anymore. Does anyone know of any good, lightweight debugging methods that I can use in embedded Linux? Even being able to view a thread's stack trace would be extremely helpful. I should mention tha...

'else' directly after end of if block

I'm interested in where this variation of the pure block style stems from. When I say putting the else directly after the end of the if block I mean... if ( foo ) { DoThis(); DoThat(); } else { DoThing(); } I noticed that the Google C++ Style Guidelines use this, but how often do you see other developers using it? Also, where do...

traverse a Binary search tree

I am trying to do a preorder traverse ...

Drawing with c++ visual studio 2010 beta?

please tell me how to draw any shape (a small square e.g) using visual studio 2010 with the c++ language ? PUT THEM STEP BY STEP PLEASE I don't know what type of file i have to choose nor how to check it out ...