Friday, May 17, 2019

class - C++ : Understanding implicit typecasting for classes with a constructor with 1 argument

Would appreciate clarification on what exactly is happening when a constructor has only one argument and it is said that it does an implicit cast to the class type - right there It is confusing to me because :



class dog {
public :

dog(string name) { mname = name;}
private :
string mname;
};


I don't understand how a type string can be converted to a type dog, I can see how it can be passed in and SET another string but if a string is converted to type dog what would that even mean? Would it be type dog that gets assigned a bit wise copy of a string?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...