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?
ans1 compiler error ...bcoz u hav defined a constructor..so now no defult constructor wud br provided....
ReplyDeleteans2 would work fine if u remove the defn...
@ankit yes you are right..:)
ReplyDelete