Examveda

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class number
{
    int i;
    public:
    int geti();
    void puti(int j);
};
int number::geti()
{
    return i;
}
void number::puti(int j)
{
    i = j;
}
int main()
{
    number s;
    s.puti(10);
    cout << s.geti( );
    return 0;
}

A. 10

B. 11

C. 20

D. 22

Answer: Option A


Join The Discussion

Related Questions on Classes and Objects in C plus plus