c++

Maintain reference to any object type in C++?

I'm trying to teach myself C++, and one of the traditional "new language" exercises I've always used is to implement some data structure, like a binary tree or a linked list. In Java, this was relatively simple: I could define some class Node that maintained an instance variable Object data, so that someone could store any kind of object...

Profiler for Visual C++ 2005

Any recommendations for gratis (i.e. free as in free beer) profilers which can be integrated with Visual C++ 2005? I'm using Very Sleepy right now (which is really nice), but wouldn't mind shifting if there were a better option. ...

Named constructor idiom and inheritance.

I have a few classes with a few named constructors. When I inherit from them, how should I inherit the constructors? The problem is that they return objects of base class and not of the child class. Side question: can I use C++0x "using" to reduce the amount of boilerplate code? ...

What is the difference between c++ dynamic binding and java dynamic binding?

What is the difference between c++ dynamic binding and java dynamic binding? ...

Mocking using boost::shared_ptr and AMOP

Hi, I'm trying to write mocks using amop. I'm using Visual Studio 2008. I have this interface class: struct Interface { virtual void Activate() = 0; }; and this other class which receives pointers to this Interface, like this: struct UserOfInterface { void execute(Interface* iface) { iface->Activate(); } }; So I try...

IHTMLDocument2->documentElement->outerHTML is too slow recreating HTML from DOM, is there a faster way?

Hi, I've got an IE BHO plugin that sends out via a COM call the HTML of a page that was loaded in the window. // Note all error handling removed for readability :) STDMETHODIMP CPlugin::get_HTML(long lMaxSize, BSTR *pbstrHTML) { CComPtr<IDispatch> pDispatch; MSHTML::IHTMLDocument2Ptr pDocument2 = NULL; MSHTML::IHTMLDocument3Ptr pDocu...

Moving development from Windows to Linux

I'm a longtime Visual Studio(from versions 6 to 2008) user that really like the editor and especially the debugger. Now I'm thinking of giving Linux a go, is there a IDE with similar, or better, capabilities out there? I'm also interested in recommendations for GUI libraries, c++ or c#. ...

Maximize CPU Usage

How do I maximize the CPU usage for my application? I tried setting it to "Real-time" in the Task Manager, but there was no noticeable improvement - it's stuck at 50%. I'm working in Windows XP with Visual C++ 2005. ...

Paths in importlib and #import to COM libraries

I am building a 32-bit C++ COM project on a 64-bit version of Windows 7. The #import looks something like: #import "C:\Program Files\Common Files\Microsoft Shared\CAPICOM\CapiCom.dll" The problem is, on x64, that directory doesn't work. If I change the path to C:\Program Files (x86)..., then the build works. But now it won't build on 3...

C++ Sound Processing

I'm looking for a library that could be used to manipulate audio files. Essentially what I would like to do is: Load an MP3/WAV file Get a 15 second clip of the file Overlay another MP3/WAV file ontop of it Render as a new MP3/WAV file ...

Concept Checking change in C++?

I'm porting over some code from one project to another within my company and I encountered a generic "sets_intersect" function that won't compile: template<typename _InputIter1, typename _InputIter2, typename _Compare> bool sets_intersect(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __...

__init__.py descends dirtree for python, but not from c++; causes "import matplotlib" error.

Why or how does the file __init__.py cause the python interpreter to search subdirectories for a module -- and why does the interpreter not honor this convention when invoked from C++? Here's what I know: Using strace on my program, I can see that the same python2.5 interpreter is being executed for both the interactive case and the ...

default arguments in constructor

Can I use default arguments in a constructor like this maybe Soldier(int entyID, int hlth = 100, int exp = 10, string nme) : entityID(entyID = globalID++), health(hlth), experience(exp), name(nme = SelectRandomName(exp)) { } I want for example exp = 10 by default but be able to override this value if I supply it in the constructor othe...

C# Hashtable vs c++ hash_map

Hi, I'm comparing the following code in C++ and C# and C# (Mono 2.4) seems to be faster. Is there anything wrong with the C++ code? #include <map> #include <string> #include <iostream> #include <ext/hash_map> #include <boost/any.hpp> int main() { //std::map<long, long> m; // hash_map is a little bit faster __gnu_cxx...

C/C++ Resources To Develop Using MetroWerks C/C++

Hello, My friend have real Macintosh IIci, that uses Mac System 7.5.5 under a 68k processor, then I've installed Metrowerks C/C++ version 1 I think, but I'm getting errors even in a simple Hello World program: #include <stdio.h> int main(void) { printf("Hello, World!"); return 0; } I'm getting this error: ·· Link Error : Li...

Is there a reverse fn() for strstr

All, I am trying to find a similar function to 'strstr' that searches a substring starting from the end towards the beginning of the string. Thanks ...

How to check if computer exists or not?

Hi! I wrote a little program, which is working like a ping command(i use ICMPSendEcho2), but it gives back a return value, not only a text message. Now I have only one question. How can I programmatically check if a hostname exist or not? I mean if i want to ping computerA, and i don't even have a computerA then it should say what the o...

#include header style

I have a question regarding "best-practice" when including headers. Obviously include guards protect us from having multiple includes in a header or source file, so my question is whether you find it beneficial to #include all of the needed headers in a header or source file, even if one of the headers included already contains one of t...

IOUSBDeviceInterface CreateInterfaceIterator does not return all interfaces

Hello, I've ran into a problem when CreateInterfaceIterator does not return all interfaces for the device. When I open "USB Prober" it says there are 9 interfaces, but displays 14 of then counting Interface #1 - Vendor-specific Interface #1 - Vendor-specific (#1) as one interface. The problem is that CreateInterfaceIte...

friendship scope c++

In section 11.5.1 of "The C++ Programming Language", Bjarne Stroustrup writes: Like a member declaration, a friend declaration does not introduce a name into an enclosing scope. For example: class Matrix { friend class Xform; friend Matrix invert (const Matrix &); //.. }; Xform x; // error: no Xform in scope Matrix (*p...