ctor-initializer tag

1 questions


1 answers
90 views
0
Why do we use colons (:) in constructors?

I saw a code like this#include <iostream>class Foo {public: int bar; Foo(int num): bar(num) {};};int main(void) { std::cout << Foo(42).bar << std::endl; return 0;}What is written her...


© 2024 OneMinuteCode. All rights reserved.