Mar 20, 2007

C++ class program (function with return value)

C++ class program (function with return value)
#include<iostream.h>
#include<conio.h>
class student // student is a class
{
public :
int add(int a,int b)
{
int c;
c=a+b;
return c;
}
};

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

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive