Original Post
If I supply a parameter type to an object constructor, does that cause the object to allow calling the '=' operator on the constructor parameter type? An example: Does this function code result in the following code to be executed..?
class Rocket
{
public:
Rocket() { SetupOtherJunk(); }
Rocket(int missle_count) { SetupOtherJunk(); FireMissles(missle_count); }
void FireMissles(int count) { ... }
private:
void SetupOtherJunk();
};
// Later in function code..
Rocket new_rocket;
..other code..
new_rocket = 5;
new_rocket.SetupOtherJunk();
..other code..
new_rocket.SetupOtherJunk();
new_rocket.FireMissles( 5 ); This doesn't make any sense at all to me. I don't know for sure what code is executed, but my IDE is allowing me to use the = operator on an integer with my class. And I have no such operation defined, other than the constructor parameter. Is there any way to prevent this from happening? I cought myself before something bad happened, but I could imagine this type of thing causing me future problems. Thanks for information.