class example {
private:
char Name[100];
public:
example() { strcpy(Name, "no_name_yet"); }
example(char n[100]) { strcpy(Name, n); }
};
int main() {
example ex;
char n[100];
cout<<"Give name ";
cin>>n;
example();
}
I want to use the constructor with the parameter so that when the user gives a name it gets copied to the name variable. How can I use the constructor with the parameter instead of the default one? I tried
example(n)
example(char n)
example(*n)
example(n[100])
but none of them work.