#is it possible to create a member of a class with pointers
1 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
what do you mean by this
pointers can't create a member, thats part of the declaration of the type
you can make pointers to members though
I meant declaring a object / instance of a class my bad
I still don't really know what you mean but I will give some examples anyway
class A {
// ...
};
A* a = /* ... */; // a pointer to an A
class A {
public:
int i;
};
A a = {1};
int* i_ptr = &a.i;// a pointer to the `i` on `a`
int A::* a_i = &A::i;// a pointer to any `i` member of an A
a.*a_i = /* ... */;// can assign to the `i` inside `a` like this
What I mean is classes are blueprints and objects are what has the data like eg objecta.inta