C++ (OOP) object oriented programming
functions in a class : functions in a class are known as methods or member functions
#include<iostream.h>
#include<conio.h>
class student // student is a class
{
public :
void add() // member function
{
int a,b,c;
cout <<"enter any number";
cin >> a;
cout <<"enter any number";
cin >> b;
c=a+b;
cout << c <<endl;
}
};
main()
{
clrscr();
student s1;
s1.add(); // calling of a function
getch();
}
No comments:
Post a Comment