Hey, why is it that the destructor of a class (that inherits something from a base class and the use of virtual is appropriate) is virtual but the constructor is not? Besides the point of the compiler not letting you anyway and that they tell you it's wrong!
Also, a copy constructor passes values in by reference right? I was wondering what would happen if it was by value instead (obviously this is wrong). But how come? I figured by passing in by reference, it would copy the actual object at that address. If you pass in by value, wouldn't it have to make a copy first? (using the copy constructor?!?!) Huh!? :huh:
Question
fault
Hey, why is it that the destructor of a class (that inherits something from a base class and the use of virtual is appropriate) is virtual but the constructor is not? Besides the point of the compiler not letting you anyway and that they tell you it's wrong!
Also, a copy constructor passes values in by reference right? I was wondering what would happen if it was by value instead (obviously this is wrong). But how come? I figured by passing in by reference, it would copy the actual object at that address. If you pass in by value, wouldn't it have to make a copy first? (using the copy constructor?!?!) Huh!? :huh:
Edited by faultLink to comment
Share on other sites
5 answers to this question
Recommended Posts