Definition

C++ Programming Language

C++ an Object-Oriented Programming language developed by Bjarne Stroustrup at Bell Laboratories in the mid-1980s as a successor to C. In C and C++, the expression C++ means “add 1 to C.

Comments are introduced by // and object types are declared as class. The part of an object that is accessible to the outside world is declared as public.

C++ lets the programmer overload operators (give additional meanings to them). For example, + normally stands for integer and floating point addition. In C++, you can define it to do other things to other kinds of data, such as summing matrices or concatenating strings.

C++ is the basis of the Java and C# programming languages.

A C++ program looks like:

// EXAMPLE.CPP
// Sample C++ program —M. Covington 1991
// Uses Turbo C++ graphics procedures

#include <graphics.h>
class pnttype {
	public:
		int x, y;
		void draw() { putpixel(x,y,WHITE); }
};
	
class cirtype: public pnttype {
	public:
		int radius;
		void draw() { circle(x,y,radius); }
};

main()
{
	int driver, mode;
	driver = VGA;
	mode = VGAHI;
	
	initgraph(&driver,&mode,”d:\tp\bgi”);
	
	pnttype a,b;
	cirtype c;
	
	a.x = 100;
	a.y = 150;
	
	a.draw();
	
	c.x = 200;
	c.y = 250;
	c.radius = 40;

	c.draw();
	closegraph;
}

In C++, input-output devices are known as streams. The statement

cout << ”The answer is ” << i;

sends “The answer is” and the value of i to the standard output stream. This provides a convenient way to print any kind of data for which a print method is defined.

 

Share it:  Cite

More from this Section

  • Inheritance
    Inheritance&nbsp;is the most important feature of Object-Oriented Programming. Inheritance ...
  • Lisp Programming
    Because of the ease with which it can handle complex data structures, Lisp is used for ...
  • ActionScript
    ActionScript is a object-oriented programming language for the Adobe Flash Player and ...
  • ASP (Active Server Pages)
    ASP (Active Server Pages) on Windows web servers, a system for generating web pages partly ...
  • Class
    A Class in object-oriented programming is a template or bluprint  that defines attributes ...