Is it possible to call a function to initialize a class in the ctor list?
I have an Angle class that I want to initialize with a random value. The Angle constructor can take an int from the random () function. Is it safe to put this call in the ctor list:
foo::foo() : Angle(random(0xFFFF)) {...}
or do I need to do this in the body of the constructor?
foo::foo() { Angle = Angle(random(0xFFFF)); ...}
If it matters, the foo class is derived from another class and has virtual methods. Also, exception handling is not allowed in our application.
+2
a source to share