MSVC++ vs g++

 

This is a short discussion about salient differences between the Microsoft Visual C++ 6.0 compiler and the g++ compiler as it pertains to this course.


1) You should always use the new C++ files in the MSVC++ compiler. That means:

	#include <iostream>
	using namespace std;
Instead of:
	#include <iostream.h>
The former is the correct style but it is not used in all iCarnegie examples.

 


 

2)  In many instances, iCarnegie has chosen the following initilization for pointer variables:

	
Node *x(head); // head is a Node pointer variable.
The fix is easy. Change to:
	Node (*x)(head); 
or
	Node *x = head;
The latter always works, the former works in most cases.

 


3) The much Ballyhooed MSVC++ scoping error.

Don't do this.
	
for(int i=0; i<10; i++){}
for(int i=0; i<10; i++){}

The compiler thinks that i is redeclared.
Do do this:
	
int i;
for(i=0; i<10; i++){}
for(i=0; i<10; i++){}


4) The getline function has a known bug when used with the console window.

Microsoft article
5) #pragma warning(disable : 4786) disables string warnings.

6) Future updates.