• Tutorials
  • Courses
  • Tracks

abs2

Last Updated :
Discuss
Comments

What would be the output of the following code snippet?

C
#include<iostream>
Using namespace std;

class implementAbstraction{
private:
   int a,b;
   void set(int x,int y)
   {
        a=x;
        b=y;
    }
    void display()
    {
       cout<<a=<<a<<endl;
       cout<<b=<<b<<endl;
    }
  };
  int main()
  { 
    implementAbstraction obj;
    obj.set(10,20);
    obj.display();
    return 0;
   }


a = 10, b = 20

a = 20, b = 10

Compilation Error

Runtime Error

Share your thoughts in the comments