Default constructor in c++


In C++;
class CExample {
public:
int a,b,c;
CExample (int n, int m) { a=n; b=m; };
void multiply () { c=a*b; };
};

For the above code what will happen if we declare object of the class as CExample c1?
What if we remove the constructor definition and then declare the object?

Comments

  1. ans1 compiler error ...bcoz u hav defined a constructor..so now no defult constructor wud br provided....

    ans2 would work fine if u remove the defn...

    ReplyDelete

Post a Comment

Popular posts from this blog