For the more Basic details about class and object of OOP go to this link
What is object oriented programming language
After reading above article i think you got the basic idea about class and object ,here now you will know how we create class and object in cpp
A basic program to understand these terms
#include<iostream>
using namespace std;
class basic
{
int length,width ; // variable of class.
public: //described below,what mean of public is.
int make_rect() // function of class
{
cout<<"Enter the length of rectangle ";
cin>>length;
cout<<"Enter the width of rectangle ";
cin>>width;
return length*width ;
}
};
int main()
{
int result;
basic b ; // creating an object
// calling the function make_rect() of class basic
result=b.make_rect();
cout<<"The rectangle area is "<<result;
}
Now understand the program line by line
first we make class named "basic " and it has threee member
two variable and one function
function is using both variable and returning their multiplication .
public:
first we make class named "basic " and it has threee member
two variable and one function
function is using both variable and returning their multiplication .
public:
0 comments: