c++

Should I add throw() to the declarations for my C++ destructors?

I have seen some C++ classes with a destructor defined as follows: class someClass { public: someClass(); ~someClass() throw(); }; Is this a good idea? I am well aware that destructors should never throw exceptions, but will this actually prevent me from throwing exceptions in my destructors? I'm not 100% sure wha...

win32 C++ printing PRINTDLGEX not declared?

I am trying to figure out how to print in C++. I want to get the device context using the PrintDlgEx function, which needs a PRINTDLGEX structure. However, I cannot create a PRINTDLGEX because it says it's undeclared. I have included the Commdlg.h and Windows.h and linked the Comdlg32.lib, but all to no avail. Is there something I'm miss...

Create thread with >70% CPU utilization

I am creating a test program to test the functionality of program which calcultes CPU Utilization. Now I want to test that program at different times when CPU utilization is 100%, 50% 0% etc. My question how to make CPU to utilize to 100% or may be > 80%. I think creating a while loop like will suffice while(i++< 2000) { cout<<" ...

getopt implementation suitable for proprietary C++ programs?

I'd like to use getopt in my C++ program, but the powers-that-be at my place don't want to use GPL or LGPL code (they're not that fond of Boost). Since getopt is licensed under the GPL (or is it the LGPL?), I can't use it. Does anyone know of any alternatives? ...

C++: Error handling problem across threads

In general I use exceptions to deal with errors, however the problem I have here is that the error applies to a different thread than the one that caused it. Basicly the window has its own thread, and the direct3d device must be created and reset by the same thread that created the window. However creating the device may fail, so I need...

Code to utilize memory more than 70%

Please tell me C++/Java code which utilize memory more than 70% . For Example we have 3 Virtual machine and in memory resources we want to test the memory utilization as per memory resources allocated by user. ...

what is the best way to check the type of base class pointer?

I want to know the runtime type of a base class pointer, I know you can use dynamic_cast. is there any better way? ...

How lean do my C++ exception classes really need to be?

There are lots of places where guidelines for designing exception classes can be found. Almost everywhere I look, there's this list of things exception objects should never do, which impacts the design of those classes. For instance, the Boost people recommend that the class contain no std::string members, because their constructor coul...

Condition evaluation in loops ?

string strLine;//not constant int index = 0; while(index < strLine.length()){//strLine is not modified}; how many times strLine.length() is evaluated do we need to put use nLength with nLength assigned to strLine.length() just before loop ...

C++ Header implementing a C# Interface

Hi. Basically I want to know if it is possible to implement a C++ header from a C# interface, because I can't make it work. Example: C# Interface: public interface A { void M( ushort u ); } C++ header: public ref class B : A { void M( unsigned short u ); } Returns "Error C3766". Thanks in advance. ...

What is the normal way to send crash reports, product registrations, etc in C++?

Hi all, What is the normal way to send crash reports, product registrations, etc? In other words, how do you guarantee your C++ Windows apps can 'call home'? I'm not a novice by any means but I'm completely lost in this area. I've never done it before so would appreciate any advice. Kind Regards, ...

Catching access violation exceptions?

Example int *ptr; *ptr = 1000; can I catch memory access violation exception using standard C++ without using any microsoft specific. ...

Can you use Boost.Regex to parse a stream?

I was playing around with Boost.Regex to parse strings for words and numbers. This is what I have so far: #include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/regex.hpp> #include <boost/range.hpp> using namespace std; using namespace boost; int main() { regex re ( "(" "([a-z]+)...

Diamond inheritance and pure virtual functions

Imagine a standard diamond inheritance. Class A defines pure virtual function fx, class B defines implementation for fx, classes C and D do nothing with fx. When trying to call fx on instance of class D you'll get 'ambiguous function call' error although there is only one implementation of fx. This can be solved by B and C inheriting fro...

Which character set to choose when compiling a c++ dll

Could someone give some info regarding the different character sets within visual studio's project properties sheets. The options are: None Unicode Multi byte I would like to make an informed decision as to which to choose. Thanks. ...

VDMEnumProcessWOW returns no processes on Vista

I'm trying to use VDMEnumProcessWOW to find all 16 bit host processes on Vista. I call it, and it appears to not find any results even though I do have a 16 bit app running. I've also tried calling VDMEnumTaskWOWEx with the process id I got for ntvdm.exe from Windows Task Manager, and that also returns no results. ntvdm.exe has user na...

C++ Classes default constructor

Earlier I asked why this is considered bad: class Example { public: Example(void); ~Example(void); void f() {} } int main(void) { Example ex(); // <<<<<< what is it called to call it like this? return(0); } Now, I understand that it's creating a function prototype instead that returns a type Example. I still don't get why ...

Why is it impossible to have a reference-to-void?

Why is it impossible to have a reference to void? The only thing I found in the C++ Standard is this line, at 8.3.2.1 A declarator that specifies the type "reference to cv void" is ill-formed. Why is it that way? Why can't I write a "generic" function that accept a void&? Just to be clear, I have no useful application in mind whe...

How can I add a new button to the navigation pane (outlook bar) in Outlook 2003/2007?

Most of us are familiar with the "accordion-style" navigation bar on the left side of Outlook 2003. It has buttons like Calendar, Tasks, Mail, etc, and clicking on one of those buttons opens up a browser pane with the list of common folders in that section. Using C++ or Delphi, I'd like to write a plugin that adds a new section to the ...

Best way to copy a vector to a list in STL ?

Is iterating through the vector using an iterator and copying to a list the most optimal method of copying. Any recommendations? ...