c++

Calling virtual method in base class constructor

I know that calling a virtual method from a base class constructor can be dangerous since the child class might not be in a valid state. (at least in C#) My question is what if the virtual method is the one who initializes the state of the object ? Is it good practice or should it be a two step process, first to create the object and th...

How to use multiple versions of GCC

We have a new application that requires glibc 2.4 (from gcc 4.1). The machine we have runs on has gcc 3.4.6. We can not upgrade, and the application must be run on this machine. We installed gcc 4.1, however, when it comes to compile time it is using all the includes, ect, from 3.4.6. How do we get around this? Any suggestions...

Convert System::DateTime to _timeb

I have a legacy C++-based application that timestamps incoming network traffic using the CRT _ftime() function. The _ftime() function returns a _timeb structure, which has a 32-bit and a 64-bit implementation. We are using the 32-bit implementation, which looks like this: struct _timeb { long time; // 4 bytes unsi...

Calculate total CPU usage

What is best algorithm for calculating total CPU usage at a particular time during execution of a process. I am working windows platform in C++. ...

Quickest way to build a bunch of DLL files with the same settings in VS 2008

Hey folks, I'm currently porting a POSIX C++ application to run on Windows without Cygwin or anything. No problem so far. Now, the application (ZNC, an IRC bouncer, in case you're interested) supports loading modules from .so shared library files on Linux/BSD etc. I ported the main executable without much of a problem, all wrapped into...

When debugging on WinCE, how can I set Visual Studio to always load symbol files it knows about?

I'm debugging a WinCE, C++ program in Visual Studio across an ActiveSync connection. Every time I start the process it fails to load symbol information. However, if I right click on the module and hit 'Load Symbols' it correctly locates the symbol information without any further prompting from me. Is there a way that I can set Visual ...

Book for going from C to C++

I know C pretty well, and I need to learn C++ pretty quickly. Does anyone know of any books, that assume a decent knowledge of C, and then goes over C++? ...

Singleton instance declared as static variable of GetInstance method

I've seen implementations of Singleton patterns where instance variable was declared as static variable in GetInstance method. Like this: SomeBaseClass &SomeClass::GetInstance() { static SomeClass instance; return instance; } I see following positive sides of this approach: The code is simpler, because it's compiler who respon...

C++ SQL Sanitization Libraries or Query Builders Offering Sanitization

In a project I am working on, I need to insert data into a SQLite3 database via C++. In order to avoid a "little Bobby Tables" incident, I need to sanitize my database inputs. I would like to find a library that does this in C++ rather than rolling my own since that usually leads to issues. Since the application will be inserting ID3 dat...

php with c++

hi friends I want to learn php from basic and want to implement php in c++ so will you tell me how to learn php ,is there any good site so that i can implement with c++ programming in UNIX environment. Thanx ...

Why can’t variables be declared in a switch statement?

I want to know more about "Why can’t variables be declared in a switch statement?" I read the post but i am not getting it exactly. You can just declare variable inside switch but to decalre and initialize a variable or to declare object of class it gives complie time error. Please explain me.... ...

Virtual functions and performance - C++

In my class design, I use abstract classes and virtual functions extensively. I had a feeling that virtual functions affects the performance. Is this true? But I think this performance difference is not noticebale and looks like I am doing premature optimization. Right? ...

why do we give int main in c++ and not void main?

why do we need to use int main and not void main in c++? ...

How drag and drop of files is done?

as in winamp or vlc player, how to do a file drag and drop? i mean i want to know what sort of coding goes into application? i want to know for c++ ...

Is there already some std::vector based set/map implementation?

For small sets or maps, it's usually much faster to just use a sorted vector, instead of the tree-based set/map - especially for something like 5-10 elements. LLVM has some classes in that spirit, but no real adapter that would provide a std::map like interface backed up with a std::vector. Any (free) implementation of this out there? ...

Why does compiling a VCC .sln run in the background with no stdout?

I'm trying to compile a project from the command line, like this: devenv.exe myproj.sln /build release It looks like the code compiles well, but that's not all I need: I want to be able to capture the output (e.g. warnings, errors) from the compiler as they occur. Unfortunately as soon as I issue the above command I am returned to th...

C++ Custom GUI Button Question

Hello! I am designing a graphical application for which I've decided to write my own menu. I would like this menu to be platform independent. For the time being, my menu will mostly consist of a number of buttons. My issue involves the handling of events when a button is clicked. My dilemma is with a button "knowing" about the conte...

Visual Studio: breakpoint excluding calls from a specific function

I want to set a breakpoint in unmanaged C++, in Visual Studio 2005, but I would like to ignore this breakpoint if the call stack is in a specific function. Is there a way to do this? ...

Minimal Qt executable-size

Now that Qt goes LGPL I tend to give it a try again. Years ago I decided against for some reasons, one of them being the huge size of executables (Qt on windows). I found a lower limit of about 5MB. Trolltech affirmed this on request but told me, that the granularity will be improved, which would lead to smaller sizes (depending on requi...

Unknown crash in a C++ Memory Pointers Exercise

I recently wrote a program to help me understand the basics of memory pointers in C++, I chose a simple prime number finder. I finally got it to work. (yay for debugging!) And I let it run to see how far it goes, it gets to prime #815389 with my verbose tells me is the 65076th prime, I get an app crash. The one thing I could think of w...