c++

Boost adjacency_list help needed

I'm trying to use Boost's adjacency_list type and I'm having trouble understanding the documentation. Say I define a class named State and I instantiate one instance for each state in the USA: class State { ... }; State california, oregon, nevada, arizona, hawaii, ... I want to enter these into a boost::adjacency_list the vertices ar...

C++ string memory management

Last week I wrote a few lines of code in C# to fire up a large text file (300,000 lines) into a Dictionary. It took ten minutes to write and it executed in less than a second. Now I'm converting that piece of code into C++ (because I need it in an old C++ COM object). I've spent two days on it this far. :-( Although the productivity di...

Select template argument at runtime in C++

Suppose I have a set of functions and classes which are templated to use single (float) or double precision. Of course I could write just two pieces of bootstrap code, or mess with macros. But can I just switch template argument at runtime? ...

Wine linker error: trying to create .lnk

I'm trying to create an .lnk file programatically. I would prefer to use C, but C++ is fine (and is what all the MSDN stuff is in). The relevant code sample is: #include <windows.h> #include <shobjidl.h> #include <shlguid.h> HRESULT CreateLink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszDesc) { HRESULT hres; IShellLink* p...

Possible to trap write to address (x86 - linux)

I want to be able to detect when a write to memory address occurs -- for example by setting a callback attached to an interrupt. Does anyone know how? I'd like to be able to do this at runtime (possibly gdb has this feature, but my particular application causes gdb to crash). ...

Header Files in C and C++

Should every .C or .cpp file should have a header (.h) file for it? Suppose there are following C files : Main.C Func1.C Func2.C Func3.C where main() is in Main.C file. Should there be four header files Main.h Func1.h Func2.h Func3.h Or there should be only one header file for all .C files? What is a better approach? ...

Nesting QDockWidgets

Right now I have four customized QDockWidgets on the left side of my application. When you start the application, each one is visible, but very small because of the visibility of each one. I would like for three of the QDockWidgets to nest behind one primary one to give that one priority and the entire left side of the screen. Does anyo...

Strange Ogre Error and A Non-Existant FIle

I am getting this error, I have no clue where: OGRE EXCEPTION(2:InvalidParametersException): Header chunck didn't match either endian: Corrupted stream? in Serializer::determineEdianness at f:\codingextra\ogre\shoggoth_vc9\ogre\ogremain\src\ogreserializer.cpp (line 90) I am using Visual Studio 2008. I tried to gvim the file on th...

The role of scripting languages in game Programming

So I've been running into a debate at work about what the proper role of a scripting language is in game development. As far as I can tell there are two schools of thought on this: 1) The scripting language is powerful and full featured. Large portions of game code are written in the language and code is only moved into C++ when perfo...

Reading File Names

Hi All, I was wondering if there's an easy way in C++ to read a number of file names from a folder containing many files. They are all bitmaps if anyone is wondering. I don't know much about windows programming so I was hoping it can be done using simple C++ methods. Thanks! ...

Access Violation

Greetings everyone, going to need some help in clearing this exception. I get the following when debugging my compiled program in Microsoft Visual C++ 6.0: Loaded 'ntdll.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\tsappcmp.d...

What is the benefit to limiting throws allowed by a C++ function?

What is the benefit of declaring the possible exception-throws from a C++ function? In other words, what does adding the keyword throw() actually do? I've read that a function declaration such as void do_something() throw(); should guarantee that no exceptions originate from the do_something() function; however, this doesn't seem to hol...

Reading File Names with C++

Hi, Is there a way to read file names from a folder using purely C(++)? That means without including windows.h (no FindFirstFile(), etc...). It doesn't look like fstream has this functionality. I know that file names are operating system dependent, but I was hoping there is some library that will allow it in windows. Thanks! ...

How to create multiple objects in the same function but without overwriting each other?

I'm trying to create an object in a function, but I am running into the problem that variable names have to be defined at runtime. Is there something I can do like with arrays that allows ne to dynamically create a variable in a function and preferably give it a different name from the one created when the function was called last? ***I...

How Do I Downgrade a C++ Visual Studio 2008 Project to 2005

How can I downgrade a C++ Visual Studio 2008 project to visual studio 2005? Maybe there is a converter program that someone knows of or otherwise a process that I can undertake. Thanks. ...

Eclipse C++ debugging breaks in STL

I'm new to debugging with Eclipse. I try to debug my app to know where it segfaults. The problem is that Eclipse breaks within the STL, which is very annoying. For example: I created a breakpoint in my source file on line 134, which works fine but if I hit F6 for "Step Over", Eclipse/gdb breaks in basic_string constructor used in the ...

Separate holder class from the reader

Continuing from the question that I asked here: C++ multi-dimensional data handling In my example: I have many Chips, each Chip has many Registers, each Register has many Cells, and each Cell has many Transistors. I asked whether to use one complex STL container for them, or to implement full classes for them. And, as advised, I chose t...

What is the benefit of inheriting from std::binary_function (or std::unary function)?

What is the benefit of inheriting from std::binary_function (or std::unary_function)? For example I have such code: class Person { public: Person(); Person(int a, std::string n); Person(const Person& src); int age; std::string name; }; Person::Person() : age(0) , name("") ...

Is std::list<>::sort stable?

I couldn't find any definitive answer to this question. I suppose most implementation use merge sort that is stable but, is the stability a requirement or a side effect? ...

Where to put the "template" and "typename" on dependent names

I implemented a "discriminated union" capable of holding C++ types, even if they have destructors etc. I implemented this as a Russian doll; i.e. Union<T1, T2, T3> derives from unionNode<T1, <UnionNode<T2, UnionNode<T3, void> > > and UnionNode<T, Tail> derives from Tail. The specialization UnionNode<T, void> holds a void* which contains ...