ExamVeda
Login
Home
Classes and Objects in C plus plus
?

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class sample1 
{
    float i, j;
};
class sample2 
{
    int x, y;
    public:
    sample2 (int a, int b) 
    {
         x = a; 
         y = b;
    }
    int result() 
    { 
         return x + y;
     }
};
int main () 
{
    sample1 d;
    sample2 * padd;
    padd = (sample2*) &d;
    cout<< padd->result();
    return 0;
}

Answer & Solution
Correct Answer: Option D
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.