c++中指向图片的指针
Just like pointers to normal variables and functions, we can have pointers to class member functions and member variables.
就像指向普通变量和函数的指针一样,我们可以具有指向类成员函数和成员变量的指针。
Let's see how this works.
让我们看看它是如何工作的。
定义类指针 (Defining a Pointer of Class type)
We can define pointer of class type, which can be used to point to class objects.
我们可以定义类类型的指针,该指针可用于指向类对象。
class Simple
{
public:
int a;
};
int main()
{
Simple obj;
Simple* ptr; // Pointer of class type
ptr = &obj;
cout << obj.a;
cout << ptr->a; // Accessing member with pointer
}
Here you can see that we have declared a pointer of class type which points to class's object. We can access data mem