I have the following code:
class Person {
public:
int age;
string name;
};
int main() {
Person ben;
ben.age = 30;
ben.name = "Ben";
Person * ptrBen = &ben;
return 0;
}
If i want to change the value stored in the age
variable of the ben
object to 35
for example, I can write in main()
:
ptrBen->age = 35;
Is there a difference between this and the following?:
(*ptrBen).age = 35;