c++ - Invoking overload constructor within constructor -
i wondering either possible in c++ run constructor overload within constructor. know possible using regular methods. tryng do:
class foo { public: foo(); foo(int val); }; foo::foo() { foo(1); } foo:foo(int val) { std::cout << val; }
this doesnt compile me. trying create 2 constructors 1 witch takes parameter , 1 sets default (the void one). aprichiate help.
class foo { public: foo(); foo(int val); }; foo::foo() : foo(1) { } foo:foo(int val) { std::cout << val; }
Comments
Post a Comment