Programming Lab: Object  Oriented Language (OOPs) AKU,PATNA

LIST OF EXPERIMENT

  1. Program to Understand class and object in C++
  2. Program to Understand constructor and destructor in C++
  3. Program to Understand Inheritance properties in C++
  4. Program to Understand Operator  Overloading Concept in C++
  5. Program to Understand Function  Overloading Concept in C++

Download in pdf Oops LAB click here

EXPERIMENT NO 1:  Program to Understand  class and object in C++.

 

Class:  A class in user defined data type decleared with keyword class that has data and function as its member whose access is governed by the three access specifier private protected and public to member of a class.

Syntax of class:  class name of class
{public/protected/private: data type declearation;
function name(){}
};
Example:     class area
{ private: int a,b;
public: get(){cout<<”Enter height and width”;
cin>>a>>b;
}

Object:  A class is a user defined data type ,which hold its own data member and                 member function,which can be accessed and used by creating instance of that class.
is called object of a class…
syntax:  class name object name; 

Ex:Write a program in c++ to Understand  class and object .

class student

{

private:
char name[30],fname[30],cls[10];

public:
    input()   //define input function

{

cout<<endl<<“Name of student :-“;

gets(name);// cin>>name;
cout<<“Enter Father’s Name:-“;

cin>>fname  ;

cout<<“Enter Class:-“;

cin>>cls;

}//end of input

show()    //define show function

{

cout<<endl<<“Name of student:- “;

puts(name);//cout.write(name,strlen(name));

cout<<“\nFather’s Name:- “;

cout<<fname;

cout<<“\nClass:-“<<cls;
}// end of show
};   //end of class

int main()

{

student   obj;       //creating the object of class

obj.input();    //call the input fun

obj.show();     //call the show fun

return 0;

}//end of main

 

OUTPUT:  Name of student:- chand
Enter father’s name:-salahuddin
Enter class:btech

 

Name of student:- chand
Father’s name:-salahuddin
class:btech

Tagged .

Leave a Reply

Your email address will not be published. Required fields are marked *