0
Why it has to be 'void' inside the class. And why we have to use (.) between the test and sayHi
2 Respuestas
+ 3
Void for what? The functions? They don't have to be. Functions inside a class can have what ever return type you want.
We use the dot to show what the class of the member we want to access is. If I had class A, and class B, both having a "sayHi" function, then how would my program know which function I wanted to call? Through the use of an object, I can call the sayHi function for the B class. Similarly, I can create another object for the A class to access that class' sayHi function.
B bobj;
A aobj;
bobj.sayHi();
aobj.sayHi();
+ 2
Thank you.. It helped me a lot