c++

How do you create a make target to run tests in NetBeans?

I'm trying to set up some unit tests using CppUnit for a C++ project I'm writing using NetBeans. Unfortunately, there's no C++ unit testing plugin available (yet?). Some helpful comments I received to this question have led me to my next question. How do I set up a separate make target through NetBeans to compile and run my tests? If...

Windows Explorer directory as bundle

I have been investigating for some time now a way to prevent my user from accidently entering a data directory of my application. My application uses a folder to store a structured project. The folder internal structure is critic and should not be messed up. I would like my user to see this folder as a whole and not be able to open it (...

invalid types 'int[int]' for array subscript

This code throws up the compile error given in the title, can anyone tell me what to change? #include <iostream> using namespace std; int main(){ int myArray[10][10][10]; for (int i = 0; i <= 9; ++i){ for (int t = 0; t <=9; ++t){ for (int x = 0; x <= 9; ++x){ for (int y = 0; y <= ...

How can you get a 4.2 release of g++/gcc for windows?

How can you get a recent release, i.e. 4.2+, of g++/gcc for windows? Mingw's standard g++ is 3.4.5 which is 3 years old, released Nov 2005. Mingw have a 4.2 version but this is only in the Alpha stage. I cannot find a stable recent release of g++ for windows, surely I must be missing something. ...

C++ templates and external function declarations.

I have this: template <typename T> class myList { ... class myIterator { ... T& operator*(); } } ... template<typename T> T& myList<T>::myIterator::operator*() { ... } That is giving me the following error: "expected initializer before '&' token". What exactly am I supposed to do? I already tried ad...

Faster bulk inserts in sqlite3?

I have a file of about 30000 lines of data I want to load into a sqlite3 database. Is there a faster way that generating insert statements for each line of data? The data is space delimited and maps directly to the sqlite3 table. Is there any sort of bulk insert method for adding volume data to a database? Has anyone devised some devio...

C++ syntax help dealing with recursive definition (or so my compiler tells me)

I'm building a game and I was compiling seeing what sort of errors were coming up and there is one there is very common and very puzzling to me: 1>c:\users\owner\desktop\bosconian\code\bosconian\ship.h(9) : error C2460: 'Ship::Coordinate' : uses 'Ship', which is being defined This also comes up for the SpaceObject class and all other ...

variable or field declared void

Hello I am working in c++: I have a function called: void initializeJSP(string Experiment) And in my MyJSP.h file I have: 2: void initializeJSP(string Experiment); And when I compile I get this error: MyJSP.h:2 error: variable or field initializeJSP declared void, the error is Where is the problem?. Thank you. ...

How do YOU reduce compile time, and linking time for Visual C++ projects? (native c++)

How do YOU reduce compile time, and linking time for VC++ projects? (native C++) Please specify if each suggestion applies to debug, release, or both. ...

Determining the alignment of C/C++ structures in relation to its members

Can the alignment of a structure type be found if the alignments of the structure members are known? Eg. for: struct S { a_t a; b_t b; c_t c[]; }; is the alignment of S = max(alignment_of(a), alignment_of(b), alignment_of(c))? Searching the internet I found that "for structured types the largest alignment requirement of any of i...

static linking on AIX with pthread

I've been reading and researching this for a couple of days now, and decided I need some outside assistance! (and this site seemed like a nice place, so I thought I'd post my question here and see how it goes) our little company hasn't built our applications on AIX for several years, and I've been assigned this task (good thing I like ...

How can I measure runtime memory requirements of an application on windows platform?

How can I measure runtime memory requirements of an application on windows platform? ...

Algorithm for finding the smallest power of two that's greater or equal to a given value

I need to find the smallest power of two that's greater or equal to a given value. So far, I have this: int value = 3221; // 3221 is just an example, could be any number int result = 1; while (result < value) result <<= 1; It works fine, but feels kind of naive. Is there a better algorithm for that problem? EDIT. There were some nic...

Template syntax

I was reading a book on templates and found the following piece of code: template <template <class> class CreationPolicy> class WidgetManager : public CreationPolicy<Widget> { ... void DoSomething() { Gadget* pW = CreationPolicy<Gadget>().Create(); ... } }; I didn't get the nested templates specified for the CreationPolicy (which is a...

Interesting C++ Abstract Function

Hi guys..... why this is happen ? When u create abstract class in c++ Ex: Class A (which has a pure virtual function) after that class B is inherited from class A And if class A has constructor called A() suppose i created an Object of class B then the compiler initializes the base class first i.e.class A and then initialize the ...

Why are destructors required in C++?

When a pointer goes out of scope, its memory is freed, so why are destructors created in c++? ...

Parse YAML Files in C/C++

I cant believe i spent two hours and not found a solution. I want a simple tutorial to show me to load a yaml file and parse the data. Expat style would be great but any solution that actually shows me the data in some form would be useful. So far i ran multiple test in yaml-0.1.1 source for C and i either get an error, no output whatso...

Getting this BST template to work.

hI, I'm trying to get this code from Larry Nyhoff's book to compile in Bloodshed. It's actually been taken word for word from the author's website, though I declared it on .cpp instead of .h (the .h file ain't working with the tester application). http://cs.calvin.edu/activities/books/c++/ds/2e/SourcePrograms/Chap12/ The search(const ...

3D Engine Comparison

I am currently investigating several free/open source OpenGL based 3D engines, and was wondering if you guys could provide some feedback on these engines and how they are to work with in a real world project. The engines being compared are (in no particular order): Crystal Space Panda3D Irrlicht These are the main ones i know that ...

boost spirit extracting first word and store it in a vector

Hi, I have problems with Boost.Spirit parsing a string. The string looks like name1 has this and that.\n name 2 has this and that.\n na me has this and that.\n and I have to extract the names. The text "has this and that" is always the same but the name can consist of spaces therefore I can't use graph_p. 1) How do I parse s...