C++ Introduction


- Info:

- C++ is OOPL - Object Oriented Programming Language.

- C++ has the same syntax as C extended to support Objects.

- C++ has the same variable types and can use the same libraries and functions as C.

- C++ was originally implemented as a pre-processor to a standard C compiler.

The pre-processor parsed the C++ source code and generated C source.

A C compiler then compiled the generated source code.

- C++ supports polymorphism, having two or more functions with the same name but different arguments.

C does not allow two functions to have the same name.

This is why C++ pre-processor generated C function name by combining the specified C++ function name and the

return and argument types of the function, which is called "name mangling."

- Additional info can be found at:

- http://www.learncpp.com

- http://publib.boulder.ibm.com/infocenter/lnxpcomp/v7v91/index.jsp


- Cons:

- Symbol "::" is used both to access class members and to define namespaces.

MyNamespace::var = 1;

MyClass::MemberVar = 1;

- Encapsulation is not done properly.

For instance to read line from file you can't use member function of file object.

Instead you use global function getline whose one parameter is file object.

C++: getline(fileObject, line);

JAVA: String line = bufferReader.readLine();

- There is a lot of confusion about having double set of header files.

Original ones with .h extension which were inherited from C.

And new ones without .h extension are the same as above but everything is placed inside std namespace.