To use parameterized constructor through explicit call

115 Views Asked by At

I am facing an error while writing this code so here in the below program code the obj1 and obj2 are called explicitly by using parameterized constructor But I am not able to get the output saying an error is obtained.

#include<iostream.h>
class num
{
 private:
  int a,b;
 public:
  void display()
  {
   cout<<"a="<<a<<"and b="<<b<<endl;
  }
}
void main()
{
 num obj1=num(10,20);
 num obj2=num(40,50);
 cout<<"First construction:";obj1.display();
 cout<<"Second construction:";obj2.display();
}
0

There are 0 best solutions below