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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -