I'm confused, just learning C++
class Person {
public:
string name;
double weight;
Person(string _name):name(_name) {}
Person(string n = "", double a = 0.0) {
name = n;
weight = a;
}
};
int main(){
// It`s ok.
Person p = Person("zhangwen",12);
cout << p.name << endl;
// It`s ok.
Person p3 = Person();
cout << p3.weight << endl;
// When I use it this way, the following error occurs. why????
// ambiguous conversion for functional-style cast from 'const char [7]' to 'Person'
Person p2 = Person("hhh");
cout << p2.name << endl;
return 0;
}