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

  • ActionScript
    ActionScript is a object-oriented programming language for the Adobe Flash Player and ...
  • C Programming Language
    C is a procedural (imperative) programming language. It is popular as an alternative to ...
  • Arithmetic unit
    Arithmetic unit is the unit of the computer that performs mathematical computations on ...
  • Variable
    Variable is a computer programming term which refers to a named memory location (storage) ...
  • Polymorphism
    In object-oriented programming, Polymorphism means the ability to use same named method ...