+ 3
Is pointer to class a good technique in c++
Hii, today I have learnt that a pointer to class works same as using an object to acess members. So I got a doubt if they both accesses variable but in a different way. Then what would be the reason for having two different things performing similar work. In a nutshell my doubt is, using a pointer object to access class members faster than using a normal object to access class members.
4 Answers
+ 3
There is no performance difference.
You will likely use pointer to class to practice polymorphism, which is a main concept of OOP and you can use pointers to do it.
On the other hand, pointer to class is basically pointer to variables, just a normal pointer.
You might also encounter pointers if you use C libraries. Since there isn't reference in C, there are lots of needs to pass pointers to functions in order to modify the arguments (kind of off-topic, but it's worth to mention).
0
Hello