Why can't I dereference a pointer to an object that's an array-element using the indirection operator?
问题 Is it not possible to dereference a pointer to an object that's stored in an array using the indirection(dereference) operator or am I doing something wrong? #include <iostream> class A { public: virtual void test() { std::cout << "A\n"; } }; class B : public A { public: void test() { std::cout << "B\n"; } }; int main() { A* v[2]; v[0] = new A(); v[1] = new B(); v[0]->test(); *(v[1]).test(); // Error! If the arrow operator is used instead // though, the code compiles without a problem. return