Friday, 17 May 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...