c++

Autotools : how to set global compilation flag

I have a project with several sources directories : src/A /B /C In each, the Makefile.am contains AM_CXXFLAGS = -fPIC -Wall -Wextra How can avoid repeating this in each source folder ? I tried to modifiy src/Makefile.am and the configure.in, but without success. I thought I could use AC_PROG_CXX to set the compilation fla...

Have I completed this C++ pointers / lists assignment? [StackOverflow Code Review? :)]

A friend of mine is studying Engineering in college. I've never studied / used C++ as I've always stuck to .NET and web based programming. When I heard her Intro. to Programming course was going to teach them the basics of C++ I decided to get her to send me notes / assignments each week so I would have some definite material to work fro...

how to show/hide SIP on Pocket PC

Hi, I have the following problem: I open the dialog, open the SIP keyboard to fill the form and then minimize the SIP. Then when I close the current dialog and return to the main dialog the SIP keyboard appears again. Does anyone know how could I show/hide SIP keyboard programatically or better what could be done to solve the described...

Event handling in Visual C++

There are two pictureboxes with two different images. If I click on one picture box, the image in it should be cleared. To make the matters worse, both of the picture boxes have only one common event handler. How can I know which picturebox generated the event? I would appreciate source code in Visual C++.net I need to know what to wr...

How best to switch from template mess to clean classes architecture (C++)?

Assuming a largish template library with around 100 files containing around 100 templates with overall more than 200,000 lines of code. Some of the templates use multiple inheritance to make the usage of the library itself rather simple (i.e. inherit from some base templates and only having to implement certain business rules). All that...

MSXML2::IXMLDOMDocument2Ptr->GetXML() messing up my string!

All, this is my code //declare string pointer BSTR markup; //initialize markup to some well formed XML <- //declare and initialize XML Document MSXML2::IXMLDOMDocument2Ptr pXMLDoc; HRESULT hr; hr = pXMLDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40)); pXMLDoc->async = VARIANT_FALSE; pXMLDoc->validateOnParse = VARIANT_TRUE; pXMLDoc...

Logging over the wire?

We have cases wherein we write a lot of log files to the host increasing the i/o on a host. Are there any good open source logging over the wire solutions. The application language is C++ on Red Hat Linux 3. ...

Multi-byte character set in MFC application

I have a MFC application in which I want to add internationalization support. The project is configured to use the "multi-byte character set" (the "unicode character set" is not an option in my situation). Now, I would expect the CWnd::OnChar() function to send me multi-byte characters if I set my keyboard to some foreign language, but...

Writing stringstream contents into ofstream

I'm currently using a std::ofstream a function and a std::stringstream std::ofstream outFile; outFile.open(output_file); Then I call a function GetHolesResults(..., std::ofstream &outFile){ float x = 1234; std::stringstream ss; ss << x << std::endl; outFile << ss; } Now my outFile contains nothing but garbage "0012E708" re...

C++ MySQL database connection

I not a DB expert, so am looking for advice for a web-based system I'm thinking of setting up. The general set up of the system I have is that it will have a web-based interface (possibly in PHP) for logging in etc, and some C++ code running on the server doing some processing. Both the PHP and the C++ code will need read/write access t...

eof detection for DirectShow

Is there a way to detect that a DirectShow filtergraph has reached the end of its file? By end of its file, I mean that a filtergraph with a SampleGrabber filter will never receive another SampleCB call. Here are some things that don't work: Trust IMediaDet::get_StreamLength (it's often says there are more frames in a video than real...

C++ Strings Modifying and Extracting based on Separators

Kind of a basic question but I'm having troubles thinking of a solution so I need a push in the right direction. I have an input file that I'm pulling in, and I have to put it into one string variable. The problem is I need to split this string up into different things. There will be 3 strings and 1 int. They are separated by a ":". ...

C++ Static member method call on class instance.

Here is a little test program : #include <iostream> class Test { public: static void DoCrash(){ std::cout<< "TEST IT!"<< std::endl; } }; int main() { Test k; k.DoCrash(); // calling a static method like a member method... std::system( "pause "); return 0; } On VS2008 + SP1 (vc9) it compiles fine : the cons...

Installer::OpenDatabase() produces a type error with msiOpenDatabaseModeTransact.

The following code produces an error hr=0x80020005 (wrong type). #import <msi.dll> using namespace WindowsInstaller; main() { ::CoInitialize(NULL); InstallerPtr pInstaller("WindowsInstaller.Installer"); DatabasePtr pDB = pInstaller->OpenDatabase( "c:\\foo\\bar.msi", msiOpenDatabaseModeTransact); } I think...

Grouping similar types of member variables together

When writing a class do you group members variables of the same type together? Is there any benefit to doing so? For example: class Foo { private: bool a_; bool b_; int c_; int d_; std::string e_; std::string f_; ... }; As opposed to: class Bar { private: std::string e_; bool a_; int d_; ...

Most used parts of Boost

When I discovered boost lexical_cast I thought to myself "why didn't I know about this sooner!" - I hated having to write code like stringstream ss; ss << anIntVal; mystring = ss.str(); Now I write mystring = boost::lexical_cast<string>(anIntVal); Yesterday, on stackoverflow, I came across boost split (another gem that will save ...

Developing as a programmer

Hi all, I have been learning C++ for three months now and in that time created a number of applications for my company. I consider myself fairly comfortable with C++ / MFC and STL, however I don't just want to be an OK programmer, I want to be a good programmer. I have a few books on best practices but I was wondering if anyone could su...

In STL maps, is it better to use map::insert than []?

A while ago, I had a discussion with a colleague about how to insert values in STL maps. I preferred map[key] = value; because it feels natural and is clear to read whereas he preferred map.insert(std::make_pair(key, value)) I just asked him and neither of us can remember the reason why insert is better, but I am sure it was not just a...

Which is preferred CTabCtrl vs. CPropertSheet in MFC?

I don't know how to use both of them. So a sample code with pros and cons is perfect. Which one is preferred? Why? ...

Single statement method to remove elements from container

Is there a single algorithm that removes elements from a container as happens in the following code? vec_it = std::remove_if( vec.begin(), vec.end(), pred ); vec.erase( vec_it, vec.end() ); ...