i have used single argument conversion function which gets called in below scenario.
the output is 100::0Code:#include<iostream> using namespace std; class Demo { public: int a,b; Demo(int i,int j=0):a(i),b(j) { } void dis() { cout<<a <<"::"<<b<<endl; } }; int main() { Demo d=100; d.dis(); return 0; }
when i changed few lines in main so that the two argument constructor gets called
It is giving error "test3.cpp: In function `int main()':test3.cpp:18: syntax error before numeric constant"Code:int main() { Demo d=100,200; d.dis(); return 0; }
But it should work as Demo d=100; works


Reply With Quote
Bookmarks