C++ is an object-oriented version of C that has been widely used to develop enterprise and commercial applications. C++ became popular because it combined traditional C programming with object-oriented programming features. Smalltalk and other OOP languages did not provide the familiar structures of conventional languages such as C and Pascal. Microsoft's Visual C++ is the most widely used C++ language.
An example:
Code:
#include <iostream>
class Bird // the "generic" base class
{
public:
virtual void OutputName() {std::cout << "a bird";}
virtual ~Bird() {}
};
class Swan : public Bird // Swan derives from Bird
{
public:
void OutputName() {std::cout << "a swan";} // overrides virtual function
};
int main()
{
Swan mySwan; // Creates a swan.
Bird* myBird = &mySwan; // Declares a pointer to a generic Bird,
// and sets it pointing to a newly created Swan.
myBird->OutputName(); // This will output "a swan", not "a bird".
return 0;
}