+ 1
which of the following statements are correct for accessing x?and why? #include <iostream> using namespace std; class test{ public: int x=9; }; int main() { test t; test *p=&t; } select all that apply:- a) t.x b) p.x c) t->x d) p->x
3 ответов
+ 2
t.x
p->x
We use the point (.) to apply on the variable
And we use (->) to apply on the address of variable the pointer
Here t is the object
And p is it pointer
So to access it the variable x of the object t
Either use pint to access the variable or (->) to access it pointer
They are the same thing probably
+ 1
thank Raizel
+ 1
Happy to help
I just hope it was useful