ExamVeda
Login
Home
C plus plus miscellaneous
?

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
struct A 
{
    private:
    int i, j, k;
    public:
    int f();
    void g();
};
int A :: f() 
{
    return i + j + k;
}
void A :: g() 
{
    i = j = k = 0;
}
class B 
{
    int i, j, k;
    public:
    int f();
    void g();
};
int B :: f() 
{
    return i + j + k; 
}
void B :: g() 
{
    i = j = k = 0;
}
int main() 
{
    A a;
    B b;
    a.f(); 
    a.g();
    b.f(); 
    b.g();
    cout << "Identical results would be produced";
}

Answer & Solution
Correct Answer: Option B
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.