I'm sure I'll botch some of the specific terminology, but what is the difference between object
and object2
in this implementation? Is the only purpose of the first method (prototyping the class's function by the same name of the class) just to save typing? At the end of the code, does object==object2
?
//first method
class Class1{
public:
int i;
Class1 (parameter);
};
Class1::Class1 (parameter){
i = 10;
}
Class1 object1(parameter);
//second method
class Class2{
public:
int i;
void function (parameter);
};
Class2::function (parameter){
i = 10;
}
Class2 object2;
object2.function(parameter);
(C++11)