applelooking applelooking - 1 year ago 64
C++ Question

What's the difference between using a.var and a.var()

Just for example

Class A{
int a;

int main(){
A test;
int b = test.a;
int c = test.a();

My question is that when accessing the member variable of a class, is there any difference between using

Answer Source

Here test.a() is a call to a function whereas test.a is access to your object's public variable, both are different things.

Also, your syntax is incorrect it should be class instead of Class.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download