c++

Concrete type or Interface?

I have the following use case , lot of code which was tightly coupled on a concrete type (say Concrete1). Later figured out the concrete type needs to be changed, so defined an interface . E.g Class ABC { virtual int foo() = 0; virtual int getType() = 0; } class Concrete1 : public ABC { int foo() { ... } int getType() ...

What editor/IDE do you use for C++ programming on linux and Why?

What editor/IDE do you use for C++ programming on linux and Why? SEE http://stackoverflow.com/questions/24109/c-ide-for-linux ...

When can you put "C++ Expert" on your CV?

Most C++ programmers will not specify their rank on their CV (at least, as far as I have seen) but some people clearly can put "C++ expert" on their CV (like most of the boost lib writers). But at which time in a programmer's evolution does he become an "expert" (in C++)? What are or should be the requirements - or what do you expect fr...

Stack,Static and Heap in C++

I've searched, but I've not understood very well these three concepts. When do I have to use dynamic allocation (in the heap) and what's its real advantage? What are the problems of static and stack? Could I write an entire application without allocating variables in the heap? I heard that others languages incorporate a "garbage coll...

Why use Web Services instead of RPC between two internal processes?

Can anyone suggest a good reason to use web services instead of RPC (not xml-rpc) as a comms channel between two C++ processes both of which will be developed by the same team? Note: Web services do not guarantee ordered delivery! ...

IOCP, Cross platform libraries?

I've recently bumped into something called IOCP on the windows platform, to be more precise: Input/Output Control Ports. This seems to be the most efficient way to code your server software when it needs to hold thousands of users concurrently. (Correct me if I'm wrong, but thread-per-socket, polling, and asynchronous callbacks (thread o...

to delete or to not delete (call func)

I remember someone saying if you create a class through a lib you should destroy it through the lib. So does this mean i shouldnt call delete? i should call myclass.deleteMe() instead? would overloading delete solve the problem? ...

Iteration over vector in C++

What is the correct way of iterating over a vector in C++? Consider these two code fragments, this one works fine: for (unsigned i=0; i < polygon.size(); i++) { sum += polygon[i]; } and this one: for (int i=0; i < polygon.size(); i++) { sum += polygon[i]; } which generates warning: comparison between signed and unsigned integer ...

Best approach for learning Java after C++?

I've been using C++ for about 6 or 7 years now, and I consider myself fluent in it. I've never bothered with Java until now, but I find myself out of the job (company went under) and I need to expand my skill set. Someone recommended Java, so I am wondering if there is any advice for where somebody like me might start. I am also inter...

Multithreaded paranoia

This is a complex question, please consider carefully before answering. Consider this situation. Two threads (a reader and a writer) access a single global int. Is this safe? Normally, I would respond without thought, yes! However, it seems to me that Herb Sutter doesn't think so. In his articles on effective concurrency he discuss...

Exception vs Assert?

Is there a rule of thumb to follow when deciding to use exceptions instead of asserts (or vice versa). Right now I do only throw if its something I think will happen during runtime on the user side (like a socket or file error). Almost everything else I use asserts. Also, if I were to throw an assert, what is a nice standard object to t...

Boost::Tuples vs Structs for return values

I'm trying to get my head around tuples (thanks @litb), and the common suggestion for their use is for functions returning > 1 value. This is something that I'd normally use a struct for , and I can't understand the advantages to tuples in this case - it seems an error-prone approach for the terminally lazy. Borrowing an example, I'd ...

How do I program an offline form of the crucial memory scanner

I like the memory scanner you can get from crucial (http://www.crucial.com/systemscanner/index.aspx) however it only works with an online computer. I would like to be able to do as much as possible of what it does, but off-line. I would like to produce sufficient info to be able to take this info to another online computer and use that...

Accessing COM interface from C or C++ in Windows environment

I'm relatively new to the Component Object Model specification - I have a simple question: How can I access a COM interface from a C or C++ application For instance, accessing Microsoft Excel COM interface to perform basic operations, without user intervention. Kind regards ...

How do I pipe output when debugging in Visual Studio 2008?

I tried going to project properties, selected debugging under configuration properties, and set command arguments to "> out.txt" (without quotation marks of course). However, when I run the program (with F5) I still see output on the console, and no out.txt file is created. This is just a simple C++ Hello World program. These steps worke...

Which project template should I use for Visual C++ game development project?

Which project template should I use for Visual C++ game development project? I am really new to Visual Studio and I am little bit confused with all these Windows Form Application, Win32 Console Application, CLR Console Application, etc. stuff. I have previously coded games in Linux and now I would like to do a pure Windows application. ...

Accessing an application's COM interface using C++ or C

In response to question, how can I (or find more information to) automate certain functionality without user intervention, from a C++ (or C) using: ATL Or Automation code directly in C/C++ Regards ...

Best practices for use of C++ header files

I have the following doubts on header files usage. 1 - Include guards placing after comments /* Copyright Note and licence information (multiple lines) */ #ifndef FOO_H #define FOO_H // Header file contents #endif Herb Sutter says in his "C++ coding standards" book that code like the above is problematic. He is saying the "#ifndef" s...

Pass by Reference / Value in C++

Hi, I would like to clarify the differences between by value and by reference. I drew a picture So, for passing by value, a copy of an identical object is created with a different reference, and the local variable is assigned the new reference, so to point to the new copy How to understand the words: " If the function modifies tha...

Factory method implementation - C++

I have the following code for "factory" design pattern implementation. class Pen{ public: virtual void Draw() = 0; }; class RedPen : public Pen{ public: virtual void Draw(){ cout << "Drawing with red pen" << endl; } }; class BluePen : public Pen{ public: virtual void Draw(){ cout << "Drawing with ...