c++

STL sorted set where the conditions of order may change

I have a C++ STL set with a custom ordering defined. The idea was that when items get added to the set, they're naturally ordered as I want them. However, what I've just realised is that the ordering predicate can change as time goes by. Presumably, the items in the set will then no longer be in order. So two questions really: Is i...

C++ Code Profiler

Can anybody recommend a good code profiler for C++? I came across Shiny - any good? http://sourceforge.net/projects/shinyprofiler/ ...

Whats the 'best' method of writing data out to a file, to be later read in again. (C++)

Hi, What is the best way of storing data out to a file on a network, which will be later read in again programmatically. Target platform for the program is Linux (Fedora), but it will need to write out a file to a Windows (XP) machine This needs to be in C++, there will be a high number of write / read events so it needs to be efficien...

SQL CE 3.5 deployment problem, concerning interop between C# and C++

Hi! We have a situation where a C# application is working with SQL CE 3.5 . To allow for a legacy program to use some of its features we have produced a C++ dll which uses interop to extract the info that it needs from the C# program. For this to work, the C#-program needs to access the database. Its not a very complex scenario. When t...

Getting started with OpenGL

As you can see here I'm about to start work on a 3d project for class. Do you have any useful resources/websites/tips/etc. on someone getting started with OpenGL for the first time? The project will be in C++ and accessing OpenGL via GLUT. Thanks! ...

Freeing memory on the heap. Should I and how?

I'm writing a CESetup.dll for a Windows Mobile app. It must be unmanaged, which I have little experience with. So I'm unsure of whether I should free the memory I allocate and how I do it. Here's the function I've written: Uninstall_Init( HWND hwndParent, LPCTSTR pszInstallDir ) { LPTSTR folderPath = new TCHA...

What is the difference between new/delete and malloc/free?

What is the difference between new/delete and malloc/free? Related (duplicate?): In what cases do I use malloc vs new? ...

Is there an easy way to use a base class's variables?

When you have a derived class, is there an simpler way to refer to a variable from a method other than: BaseClass::variable EDIT As it so happens, I found a page that explained this issue using functions instead: Template-Derived-Classes Errors. Apparently it makes a difference when using templates classes. ...

Print really big numbers

Hey! I have this code #include <iostream> using namespace std; int main(int argc,char **argv) { unsigned long long num1 = 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999...

Linker Errors C++ Visual Studio 2005

I'm getting a whole bunch of linker errors in Visual studios for methods I'm not even calling directly. I'm a java developer by day, but I have a project I need to do in C++, intended to run on windows machines. Hence, I'm stuck messing about with Visual Studio. Bascally, I have an os project that I added an accessor method to. I compil...

How to set an initial size of a QScrollArea?

I know that this is a very specific C++ and Qt related question, but maybe someone can help me, anyway ... See the code below: I want to display an image within a scroll area. The view port of the scroll area shall have a defined initial size. That means, if the image's size is bigger than the initial size of the view port, scroll bars ...

How do I view the contents of an IXMLDOMElementPtr when building an XML file?

I'm using IXMLDOM in MSXML 6 to build an XML file in a C++ MFC application. Is there a way to see the contents of the xml document while it is in memory? For example, an XPATH query is failing about halfway through creating the file. How would I view the entire contents of the xml doc? Thanks! ...

Python snippet to remove C and C++ comments

I'm looking for Python code that removes C and C++ comments from a string. (Assume the string contains an entire C source file.) I realize that I could .match() substrings with a Regex, but that doesn't solve nesting /*, or having a // inside a /* */. Ideally, I would prefer a non-naive implementation that properly handles awkward case...

How do I get a list of domain user accounts with win32 api?

How do I get a list of domain user accounts with win32 api? In particular, I can't get this list when the computer is not the domain controller. Instead it is a member of the domain. ...

Howto determine the size of a string give the current font in wxWidgets

Is there a way to determine the display length of a given string (in pixels) based on the currently selected font in (C++) wxWidgets? For example if I print out the string "Speed:" and want to put 10 pixels between the ':' and the value about to follow, I need to know how long the "Speed:" string was. Is there a way to determine this? ...

Boost C++ libraries for gcc-arm toolchain

I have no trouble building 1.35.0, as well as 1.36.0 on the timesys arm-gcc toolchain, both statically (link-static) as well as dynamically (.so, default option). However, when I try to link a simple sample filesystem app: #include <boost/filesystem.hpp> #include <iostream> namespace fs = boost::filesystem; int main(int argc, char *a...

Gentle introduction to JIT and dynamic compilation / code generation.

The deceptively simple foundation of dynamic code generation within a C/C++ framework has already been covered in another question. Are there any gentle introductions into topic with code examples? My eyes are starting to bleed staring at highly intricate open source JIT compilers when my needs are much more modest. Are there good te...

Checking lists and running handlers

I find myself writing code that looks like this a lot: set<int> affected_items; while (string code = GetKeyCodeFromSomewhere()) { if (code == "some constant" || code == "some other constant") { affected_items.insert(some_constant_id); } else if (code == "yet another constant" || code == "the constant I didn't mention yet...

Is this C++ implementation for an Atomic float safe?

Edit: The code here still has some bugs in it, and it could do better in the performance department, but instead of trying to fix this, for the record I took the problem over to the Intel discussion groups and got lots of great feedback, and if all goes well a polished version of Atomic float will be included in a near future release ...

C++/Unix Home Project Ideas

I am a C++, Unix developer, mostly in systems side, product domain. I would like to take up some side project to improve my skills in the following : Object oriented Design Multithreaded Programming, with ample scope for mutexes and semaphores Interprocess Communications in Unix Core C++ stuff (wanna use templates, handle exceptions, u...