0
C++ objects and the dot operator
classname object.datavariable=2323 (or any other value) This would mean access the datavariable of the object and initialize the datavariable of object a value of 2323. I get this. Its similar to like int a=4? But with object.function() I am trying to understand how a program would interpret this. Access the object's data variables and do something to them via function()? If I wanted to use a member function inside main, I HAVE to use it with an object right?
1 Antwort
+ 4
Exactly that 👍 your code in main will look somthing like.
//Using constructor will initalize your object.
YourClass object = new YourClass(5,5);
object.function();