Mar 20, 2007

Function with parameter in a class

C++ (OOP) object oriented programming
function with parameter in a class.

#include<iostream.h>
#include<conio.h>
class student
{
public :
void add(int a,int b)
{
int c;
c=a+b;
cout << c <<endl;
}
};

main()
{
clrscr();
student s1;
int a,b,c;
cout <<"enter any number";
cin >> a;
cout <<"enter any number";
cin >> b;
s1.add(a,b); // calling of a function
getch();
}

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive