Posts

Showing posts with the label CPP TUTORIAL

Definition and example of parameterized constructor.

PARAMETERIZED CONSTRUCTOR: - These are the constructors with parameter. Using this Constructor you can provide different values to data members of different objects, by passing the appropriate values as argument. The constructor with parameters can be used to initialize data members of the object. To create a constructor with parameters you have to specify its parameters in the parentheses as we do to specify parameters of a function. e.g. #include<iostream.h> #include<conio.h> class number { int itemcode,cost; public: number(int x,int y) { itemcode=x; cost=y; } void display() { cout<<"\n code= "<<itemcode; cout<<"\n cost= "<<cost; } }; void main() { clrscr(); number n1(192,356); cout<<"values for first object="; n1.display(); number n2(546,657); cout<<"\n value for second object="; n2.display(); getch(); }

EXAMPLE OF DEFAULT CONSTRUCTOR

Image
DEFAULT CONSTRUCTOR:-A constructor in which we can not pass any parameter this types of constructor are called default constructor. E.G.

WHAT IS CONSTRUCTOR ?

A Constructor is a special member function of class because its name is same as the class name.it is called constructor because it construct the values of the data member of the class and it cannot return any values. if a class has constructor each object of that type is initilized with the constructor to use in a program.constructor are called at the point where an object of the class is created.

What is programming language?

Introduction to Programming Languages A computer is a computational device which is used to process the data under the control of a computer program. Program is a sequence of instruction along with data. While executing the program, raw data is processed into a desired output format. These computer programs are written in a programming language which are high level languages. High level languages are nearly human languages which are more complex then the computer understandable language which are called machine language, or low level language. Between high-level language and machine language there are assembly language also called symbolic machine code. Assembly language are particularly computer architecture specific. Utility program ( Assembler ) is used to convert assembly code into executable machine code. High Level Programming Language are portable but require Interpretation or compiling toconvert it into a machine language which is computer understood. Most Popular Pr...