Thursday, March 17, 2011

Cpp program2

/* Assume a member function , get_num(), with return vlue of type int is declared inside a class called Calcuator.
Write a typical class specifier and declare the member function. Also write the definition of the function outside the class
specifier.
*/

# include "iostream"
using namespace std;
# include "stdio.h"

class Calculator
{
protected:
int nData;

public:
int get_num();
};



int Calculator ::get_num()
{
/* the member whoes declaration is within the calculator class spcifier consider to be access variabl*/

nData = 10000;

printf("%d\n",nData);

return nData;
}

int main()
{

Calculator Obj;
Obj.get_num();

return 0;
}


OUTPUT:

10000
Press any key to continue . . .

No comments:

Post a Comment