Thread: C++ Tutorial I
View Single Post
Newbie Member
10Oct2008,17:00  
victor2008's Avatar
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;
}

Last edited by shabbir; 11Oct2008 at 09:54.. Reason: Confine links to signatures only.