c++

How can you link to a different version of MFC from a Visual C++ project in Visual Studio 2010?

I have a VC++ project in VS2010 that is linking to some dll's built with VS2008. Works fine until I try to pass MFC objects to the VS2008 dll. The artifact of the VS2010 VC++ project (a .dll) is linking against the latest version of MFC that shipped with VS2010, whereas the VS2008 .dll is linking against the previous version of MFC tha...

convert std::string to basic_ostream?

Is there a conversion for the above? ...

OpenCV - VideoWriter produces a video with a "repeated" image

I'm trying to process each frame in a pair of video files in OpenCV and then write the resulting frames to an output avi file. Everything works, except that the output video file looks strange: instead of one solid image, the image is repeated three times and horizontally compressed so all three copies fit into the window. I suspect ther...

C++ case declaration?

I am trying to adapt a digital electronics problem to a C++ STL based program. Originally I have 4 inputs C1, C2, C3, C4. This means I have a total of 16 combinations: 0000 0001 . . . 1111 I have a multimap defined by typedef std::pair<int, int> au_pair; //vertices typedef std::pair<int, int> acq_pair; //ch qlty typedef std::multim...

In C++, Is it good form to write code that executes before main()?

The constructors of globally declared classes are invoked before main is entered. While this can be confusing to a new reader of the code because it is done so infrequently, is it necessarily a bad idea? ...

effeciently read large spreadsheet file in C++

I normally use the method described in csv parser to read spreadsheet files. However, when reading a 64MB file which has around 40 columns and 250K rows of data, it takes about 4 minutes. In the original method, a CSVRow class is used to read the file row by row, and a private vector is used to store all the data in a row. Several thin...

Where is disable_if in C++0x?

Boost has both enable_if and disable_if, but C++0x seems to be missing the latter. Why was it left out? Are there meta-programming facilities in C++0x that allow me to build disable_if in terms of enable_if? Oh, I just noticed that std::enable_if is basically boost::enable_if_c, and that there is no such thing as boost::enable_if in C...

c++ static function unfound

I have this definition of the function in my class. The .hpp file: class SomeClass { public: static string DoStuff(string s); }; The .cpp file: #include "header.hpp" string SomeClass::DoStuff(string s) { // do something } Compiler says: **error C2039: 'DoStuff' : is not a member of 'SomeClass'** Can somebody help? EDIT: act...

How do I configure Qt to work with Visual Studio 2010?

I downloaded open-source version of Qt from the site and have compiled it with nmake, but I'm having trouble using it in my projects. It seems that Visual Studio can't find the Qt headers, even though I added the paths to my PATH, INCLUDE, and LIB variables. I tried installing the Qt Visual Studio add-in but it only supports Visual Studi...

Find width of a tab item? (WinAPI)

I want to be able to know how much room a particular tab takes up, is there a way to calculate this knowing it's text and having its item struct? Thanks ...

Unqualified name in IDL for imported type library

I've created a COM-class that implements some interface. I want to add a method to this interface. The parameter of this method is a pointer to the interface defined in some external olb-file. In my project this olb-file imported without no_namespace directive. So, the interface name in the parameter of the method must be qualified in h\...

Make a template accept a specific class/family of classes?

I have a template method that is designed to work with a specific set of classes. Since I have no real need for runtime polymorphism, I've decided to not use pointers to the parent class, but rather will have the compiler put everything together for me. I want to either restrict the type that can be passed to the template, or make GCC ...

safe integer conversion in c++

Hello, I want to create a simple integer range checker and converter using c++ templates. The code looks like this: // D is the "destination" type and S the "source" type template <class D, class S> inline D SafeConvert( S value ); template <class S> inline int SafeConvert<int>( S value ) { ASSERT( value >= S(INT_MIN) && value <= ...

How many passes over the code does gcc use?

Specifically for C and C++, how many passes are used by default? Does this number change depending on the level of optimization used? (it should) Can it be changed directly? I was searching for this information in http://gcc.gnu.org/, but googling using site:http://gcc.gnu.org/ did not yield anything. Any pointers to any documentati...

How to create a library and call the header files using < > instead of ""?

Hello, I've been writing a library lately for my C++ computer class. I would like to put all my .lib and my header files inside a folder outside the project that's going to be calling the library. How can I call the library header files using the < > operators instead of the " "? I'm using visual studio [specifically VS03] Thanks, Y_Y...

How do I get the MAC/Serial of a DVB device on Linux?

I have a couple of Hauppage 950Q USB tuners attached to a Linux PC (CentOS) and I want to be able to differntiate which one is which. On windows I can query the MAC of the USB tuners to accomplish this, but on Linux I am not sure how to do that because this functionality is not exposed (to my knowlege) by the video4linux API that I'm ac...

c++ inherit from a virtal base class

I want to do the following: class ErrorBase { public: void SetError(unsigned errorCode) { mErrorCode = errorCode; } char const* Explanation(unsigned errorCode) const { return errorExplanations[errorCode]; } private: char const* errorExplanations[]; unsigned mErrorCode; }; class MyErro...

C++: pointer-to-member-func, template & inheritance mixup

I am trying to create a generic "callback" object that will hold arbitrary data and invoke member functions of related classes. Due to internal policy, I cannot use Boost. The callback object looks like this: template<typename Object, typename Data> class Callback { public: typedef void (Object::*PHandler)(Callback*); Callback(Obj...

how to transfer C++ number format to C# number format?

have the flowing C++ code: CString info, info2; info.Format("%2d", Value[i]); info2.Format("%4.1f", Value[j]); want to have the equivalent code in C# how to do it? ...

Perform CRUD for todos/tasks/appointments from Outlook?

How can I perform CRUD (Create, Read, Update, Delete) for todos/tasks/appointments/etc from Outlook. Does Microsoft have a data api like Google that I can use to interact with Microsoft applications? I prefer this in C++ (Microsoft Visual C++), but Java will also work. ...