c++

Template function passed to shared library (c++)

Bit of a thought experiment... Ingredient 1: A class in a (precompiled) shared library that has a function that takes a pointer to an object derived from ostream: void ClassName::SetDefaultStream(std::ostream *stream) Ingredient 2: My own class deriving from std::ostream, with some generic templated stream operator: class MyStream :...

Debugging a DLL in VS2005 (C++)

I have a dll project in a solution that I want to debug. The calling application is in a different path and the DLL must be placed inside that path. When I build the debug version and copy+paste the produced DLL into the calling application's path, I get an error message that there are no symbols and that the binary wasn't built by the ...

may COM server reallocate ([in, out] CACLSID * arg) ?

With a COM interface method declared as this: [ object, uuid(....), ] interface IFoo : IUnknown { HRESULT Foo([in, out] CACLSID * items); } With regards to marshalling, is the server allowed to reallocate the counted array? (I think it is, but I am not sure anymore) Its current implementation only replaces the existing ID's, but...

Java priority queue

Java's priority queue is a data structure with O(log n) complexity for put (insertion) and O(log n) for poll (retrieval and removal of the min element). C++ STL's multimap has the same functionality but O(1) complexity for retrieval and removal of the min element (begin and erase). Is there an equivalent in Java ? ...

How can I use C++ class in Python?

I have implemented a class in C++. I want to use it with Python. Please suggest step by step method and elaborate each step. Somthing like this... class Test{ private: int n; public: Test(int k){ n=k; } void setInt(int k){ n = k; } int getInt(){ ...

Template or abstract base class?

If I want to make a class adaptable, and make it possible to select different algorithms from the outside -- what is the best implementation in C++? I see mainly two possibilities: Use an abstract base class and pass concrete object in Use a template Here is a little example, implemented in the various versions: Version 1: Abstract...

Computing BITMAPINFOHEADER biCompression value for monochrome BMP

Hi all, Hopefully someone has an answer, and it's not TOO complex. I'm working on a C++ dll (no C# or .Net, fully static DLL). Anyhow, its woring on buildin monochrome bitmaps. I have all of it working EXCEPT the resolution. I get the Device Context, Get Compatible Device Context, build bitmap, draw what I need to (as black/white), ...

What project would you recommend me to get up to speed with C++

I know that C++ is a very complex language that takes many years of practice to master. Taking that into account do you know of a small project (around a 1k of loc) that tests all of C++ major features (inheritance, pointers, memory management, etc). The thing is I'm a Java/Python programmer and I really want to learn C++ so I've been st...

Print Date and Time In Visual Studio C++ build?

How would I print the date and time for the purposes of the build. Ie: When the console for my application starts up I want to do this: Binary Build date: 03/03/2009 @ 10:00AM I think this would be a super useful function for all applications to have behind the scenes for programmers, especially in a team environment. Is there a si...

Using the g++ C++ compiler from cygwin

I am trying to execute my first "Hello World!" in C++. I am using Windows XP, and I have installed cygwin, in which the g++ C++ compiler is installed. I have written a small hello-world program, and saved it in hello.cpp. From the command prompt I write: g++ hello.cpp But I get: 'g++' is not recognized as an internal or extern...

Fonts for Carbon OpenGL app on OS X

Hi, I'm trying to add text rendering to a Carbon OpenGL app I'm developing for OS X. Since the aglUseFont is now deprecated, I'm looking for another way to add text as well as be able to query the glyph properties (i.e. width, height, spacing, etc) So far I've investigated CoreText and ATSUI but both without much luck. Please help me...

c++ namespace usage and naming rules.

On the project we are trying to reach an agreement on the namespace usage. We decided that the first level will be "productName" and the second is "moduleName". productName::moduleName Now if the module is kind of utility module there is no problem to add third namespace. For example to add "str": productName::utilityModuleName::str ...

Inline member functions in C++

ISO C++ says that the inline definition of member function in C++ is the same as declaring it with inline. This means that the function will be defined in every compilation unit the member function is used. However, if the function call cannot be inlined for whatever reason, the function is to be instantiated "as usual". (http://msdn.mic...

Using STL port in VS2008

Hi there, I am working on porting our C++ code from eVC 4.0 to Visual Studio 2008. Our target is Windows Mobile 6.1 and we are using the Windows Mobile 6.0 SDK for our app. Our code used stl port when compiled in eVC 4 and we would like to continue to use stl port if at all possible. Does anyone know what steps are necessary to inc...

STL removing elements that match a predicate

Hi Folks, I have a source container of strings I want to remove any strings from the source container that match a predicate and add them into the destination container. Remove_copy_if and other algorithms can only reorder the elements in the container, and therefore have to be followed up by the erase member function. My book (Josutti...

Switch from Microsofts STL to STLport

Hi! I'm using quite much STL in performance critical C++ code under windows. One possible "cheap" way to get some extra performance would be to change to a faster STL library. According to this post STLport is faster and uses less memory, however it's a few years old. Has anyone made this change recently and what were your results? ...

OpenGL cross platform window

I'm looking for a window... ugh... thing for OpenGL, I've been using SDL but more recently found that its not quite up to my needs in at least any code I've seen. I'd like to find some GUI library that allows me to develop using OpenGL (and SDL if at all possible) with a menu bar, possibly options at the side, and a working-out-of-the-bo...

how-to: programmatic install on windows?

Can anyone list the steps needed to programatically install an application on Windows. Aside from copying the files where they need to be, what are the additional steps needed so that your app will be a first-class citizen in Windows (i.e. show up in the programs list, uninstall list...etc.) I tried to google this, but had no luck. BTW...

about c++ exceptions. func() throw()

i am reading this page http://www.cplusplus.com/doc/tutorial/exceptions.html it says if i write function() throw(); no exceptions can be thrown in that function. I tried in msvc 2005 writing throw(), throw(int), throw() and nothing at all. each had the exact same results. Nothing. I threw int, char*, another type and it was all caught th...

C++ reading unsigned char from file stream

I want to read unsigned bytes from a binary file. So I wrote the following code. #include <iostream> #include <fstream> #include <vector> #include <istream> std::string filename("file"); size_t bytesAvailable = 128; size_t toRead = 128; std::basic_ifstream<unsigned char> inf(filename.c_str(), std::ios_base::in | std::ios_base::binary)...