C++ constructor arguments
Bozo(const char * fname, const char * lname); // constructor prototype
In this case, you would use it to initialize new objects as follows:
Bozo bozetta = bozo("Bozetta", "Biggens"); // primary form
Bozo fufu("Fufu", "O'Dweeb"); // short form
Bozo *pc = new Bozo("Popo", "Le Peu"); // dynamic object
I just have a few questions regarding this. First is that, why is const
needed before char? or why is it there?. Also, why is it declaring as a
pointer?
Second, is there any difference between the "primary form" and the "short
form?"
Third question is that in Java, I used string variables for the formal
parameters, but in C++ it's in char? I thought char can only contain a
single alphabet, and it's not a char array. Could I do this with string
instead?
No comments:
Post a Comment