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?

18th Mar 2019, 8:42 PM
J3fro C
J3fro C - avatar
1 Answer
+ 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();
18th Mar 2019, 9:33 PM
D_Stark
D_Stark - avatar