c++

Future proofing a large UI Application - MFC with 2008 Feature pack, or C# and Winforms?

My company has developed a long standing product using MFC in Visual C++ as the defacto standard for UI development. Our codebase contains ALOT of legacy/archaic code which must be kept operational. Some of this code is older than me (originally written in the late 70s) and some members of our team are still on Visual Studio 6. However,...

How to prevent an object being created on the heap?

Does anyone know how I can, in platform-independant C++ code prevent an object from being created on the heap? That is, for a class "Foo", I want to prevent users from doing this: Foo *ptr = new Foo; and only allow them to do this: Foo myfooObject; Does anyone have any ideas? Cheers, ...

How should I unit test a code-generator?

This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions. I have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did i...

In C++/Windows how do I get the network name of the computer I'm on?

In a C++ Windows (XP and NT, if it makes a difference) application I'm working on, I need to get the network name associated with the computer the code is executing on, so that I can convert local filenames from C:\filename.ext to \\network_name\C$\filename.ext. How would I do this? Alternatively, if there's a function that will just do...

GCC problem : using a member of a base class that depends on a template argument

The following code doesn't compile with gcc, but does with Visual Studio: template <typename T> class A { public: T foo; }; template <typename T> class B: public A <T> { public: void bar() { cout << foo << endl; } }; I get the error: test.cpp: In member function ‘void B<T>::bar()’: test.cpp:11: error: ‘foo’ was not declared ...

String To Lower/Upper in C++

What is the best way people have found to do String to Lower case / Upper case in C++? The issue is complicated by the fact that C++ isn't an English only programming language. Is there a good multilingual method? ...

How to overload std::swap()

std::swap() is used by many std containers (such as std::list and std::vector) during sorting and even assignment. But the std implementation of swap() is very generalized and rather inefficient for custom types. Thus efficiency can be gained by overloading std::swap() with a custom type specific implementation. But how can you impleme...

Case insensitive string comparison in C++

What is the best way of doing case insensitive string comparison in C++ with out transforming a string to all upper or lower case? Also, what ever methods you present, are they Unicode friendly? Are they portable? ...

Inheritance and Polymorphism - Ease of use vs Purity

In a project our team is using object lists to perform mass operations on sets of data that should all be processed in a similar way. In particular, different objects would ideally act the same, which would be very easily achieved with polymorphism. The problem I have with it is that inheritance implies the is a relationship, rather th...

_wfopen equivalent under Mac OS X

I'm looking to the equivalent of Windows _wfopen() under Mac OS X. Any idea? I need this in order to port a Windows library that uses wchar* for its File interface. As this is intended to be a cross-platform library, I am unable to rely on how the client application will get the file path and give it to the library. ...

In a C/C++ program how does the system (windows, linux, mac OS X) call the main() function.

I am looking for a more technical explanation then the OS calls the function. Can anyone help me out or point me to a website or book? Thanks. ...

Windows/C++: How do I determine the share name associated with a shared drive?

Let's say I have a drive such as "C:\", and I want to find out if it's shared and what it's share name (e.g. "C$") is. To find out if it's shared, I can use NetShareCheck. How do I then map the drive to its share name? I thought that NetShareGetInfo would do it, but it looks like that takes the share name, not the local drive name, as ...

What is the easiest way to parse an INI File in C++?

I'm trying to parse an INI file using C++. Any tips on what is the best way to achieve this? Should I use the Windows API tools for INI file processing (with which I am totally unfamiliar), an open-source solution or attempt to parse it manually? ...

C++ Problems with #import of .NET out-of-proc server.

In C++ program, I am trying to #import TLB of .NET out-of-proc server. I get errors like: z:\server.tlh(111) : error C2146: syntax error : missing ';' before identifier 'GetType' z:\server.tlh(111) : error C2501: '_TypePtr' : missing storage-class or type specifiers z:\server.tli(74) : error C2143: syntax error : missing ...

How to combine several C/C++ libraries into one?

I'm tired of adding ten link libraries into my project, or requiring eight of them to use my own. I'd like to take existing libraries like libpng.a, libz.a, libjpeg.a, and combine them into one single .a library. Is that possible? How about combining .lib libraries? ...

How does one rank an array (sort) by value? *With a twist*

Hi all, I need to take an array and sort it in c/c++, replacing each value with its' "rank", an integer that corresponds to its position after sort. Heres an example: Input: 1,3,4,9,6. Output: 1, 2, 3, 5, 4. So, I need to replace each value with its position relative to all the other values. I hope that makes sense, but its late, so...

GUI system development resources?

Could someone recommend any good resources for creating Graphics User Interfaces, preferably in C/C++? Currently my biggest influence is 3DBuzz.com's C++/OpenGL VTMs (Video Training Modules). While they are very good, they cover a large area of graphics programming, so only skim the surface of GUI programming. This question does relate...

Choosing a C++ unit testing tool/framework

Could you recommend a testing tool/framework to use for testing C++ code in a UNIX environment? ...

Any windows apis to get file handles besides createfile and openfile?

I am trying to snoop on a log file that an application is writing to. I have successfully hooked createfile with the detours library from MSR, but createfile never seems to be called with file I am interested in snooping on. I have also tried hooking openfile with the same results. I am not an experienced windows/c++ programmer (or ev...

How to create a C++ Boost undirected graph and traverse it in depth first search (DFS) order?

How to create a C++ Boost undirected graph and traverse it in depth first search (DFS) order? ...