c++

Visual Studio 2005 (C++) default warning level

I'm working on a new development in C++, using MS Visual Studio 2005. For this, I need to add several new projects to my solution. I always set my warning level to 4, and turn on "treat warnings as errors" (project -> properties -> c++ -> general). Is there a way for me to tell Visual Studio that this is my default so I don't have to do...

What is the point of pointer types in C++?

Let's say I have some pointers called: char * pChar; int * pInt; I know they both simply hold memory addresses that point to some other location, and that the types declare how big the memory location is pointed to by the particular pointer. So for example, a char might be the size of a byte on a system, while an int may be 4 bytes.. ...

Multiple Inheritance

#include<iostream> using namespace std; class A { int a; int b; public: void eat() { cout<<"A::eat()"<<endl; } }; class B: public A { public: void eat() { cout<<"B::eat()"<<endl; } }; class C: public A { public: void eat() { cout<<"C::eat()"<<endl; } }; class D: pub...

Using .NET class from native C++ using C++/CLI as a 'middleware'

I have to use a class/assembly made in C# .NET from native C++ application. I suppose I need to make a wrapper class in C++/CLI, that would expose native methods in header files, but use .NET class as needed. Thing that's unclear to me is how to convert data types from .NET to standard C++ types. Does anybody have some sample code to l...

What is the format of a Borland 5.0 project file?

I have an old Borland project which I would like to port to VS2008. Is there any way to dump, in a human readable format, the source file, compile options and dependency information from a .ide file? I'd like something a bit more comprehensive than the 'Generate Makefile' option. ...

Dev C++ Compiled Exe Information

When I compile my project in Dev C++ how can I get information displayed on the summary page of the exe properties in windows? I have tried using the "Version Info" tab in project properties with no luck. ...

The C++ .NET programmer's bookshelf

I'm buying a lot of books, but I feel I don't hit the good ones. So, I leave it up to you to suggest what books a C++ .NET programmer should have in the bookshelf. Preferably it should contain books with level from novice to expert level, and I believe it should contain more than one single book. ...

crash on vector::push_back

I have a vector that contains POSITIONs. When I try to push_back or clear, the program crashes. The callstack shows _invalid_parameter_noinfo in one of the frames. I googled and found a solution(defining _HAS_ITERA.... and _SECURE_SCL to 0) , but was not effective. I'm using VS2008 with MFC feature pack installed on vista. Please help. ...

Network interface settings

How can we get the network interface name (i.e. the one that appears in the "Network connections" dialog) given the device description (i.e. the string that appears in the "Device Properties -> Connect using:" textbox)? We must do it in pure C/C++ language, or through some of the standard command line tools (e.g. netsh, ipconfig...), or ...

CVSListBox notification after delete

I've just added one of the new (MFC Feature Pack) CVSListBox controls to a project. The list of items in the control is tracked by some other objects in my application, so I need to take lots of notifications from the list-box when anything changes so that I can update other stuff. For those that don't know the control, there is a butt...

MFC SetRegistryKey... Is there a GetRegistryKey function?

I have these two lines of code. CString strHost = AfxGetApp()->GetProfileString(_T("WebServices"), _T("Server")); AfxMessageBox(strHost); Nowhere in the app do I set the value. (the installer does that). So the strHost, should be the same no matter where or when this line is run. Here's what I've got. Press A -> run function that ...

C++ : friend AND inline method, what's the point ?

Hello, I see in a header that I didn't write myself the following : class MonitorObjectString: public MonitorObject { // some other declarations friend inline bool operator==(MonitorObjectString& lhs, MonitorObjectString& rhs) { return(lhs.fVal==rhs.fVal); } I can't understand why this method is declared as friend. I thought ...

Looped push_back against resize() + iterator

Simple question; what's better and why? out.resize( in.size() ); T1::iterator outit = out.begin(); for( inIt = in.begin() to end, ++inIt, ++outIt ) *outit = *inIt OR out.erase(); for( inIt = in.begin() to end, ++inIt ) out.push_back( inIt ); I'm assuming the memory assignment implicit in push_ba...

An operator == whose parameters are non-const references

I this post, I've seen this: class MonitorObjectString: public MonitorObject { // some other declarations friend inline bool operator==(/*const*/ MonitorObjectString& lhs, /*const*/ MonitorObjectString& rhs) { return lhs.fVal==rhs.fVal; } } Before we can continue, THIS IS VERY IMPORTANT:...

lightweight boost::bind

I'm so sick of the pass-callback-data-as-void*-struct anti-pattern. Boost bind solves it nicely, but is an unacceptable dependency. What's a lightweight alternative? How would I write it myself as simply as possible? ...

In C arrays why is this true? a[5] == 5[a]

As Joel points out in Stack Overflow podcast #34, in C Programming Language (aka: K & R), there is mention of this property of arrays in C: a[5] == 5[a] Joel says that it's because of pointer arithmetic but I still don't understand. Why does a[5] == 5[a] ? Edit: The accepted answer is great. For a lower level view of how this works, se...

Using arrays or std::vectors in C++, what's the performance gap?

In our C++ course they suggest not to use C++ arrays on new projects anymore. As far as I know Stroustroup himself suggests not to use arrays. But are there significant performance differences? ...

C/objC/C++/Java compilers

I downloaded NetBeans (for first time) to use Java and found that it can handle C/C++ etc too. Wanted to know following -- 01- Is there any better C++ tool (IDE) other than NetBeans and MS Visual Studio? Better means very mature and popular (and free). 02- What is the difference between GNU Java and Sun Java compilers? 02- Is there...

Best base type to deal with linear algebra

I'm writing a small and inadequate linear algebra library in C++ for a project (I'm sorry). I'm implementing matrices and operations using double precision numbers. I'm doing right? Should I implement a template class instead? Is there a more precise type around? ...

Check for pointer definedness in C++

How do I check if a variable, specifically a pointer, is defined in C++? Suppose I have a class: class MyClass { public: MyClass(); ~MyClass() { delete pointer; // if defined! } initializePointer() { pointer = new OtherClass(); } private: OtherClass* pointer; }; ...