What type of cast takes place here (in B::get()
)?
class A {
public:
A() : a(0) {}
int a;
};
class B : public A {
public:
A* get() {
return this; //is this C-style cast?
}
};
int main()
{
B b;
cout << b.get()->a << "\n";
system("pause");
return 0;
}
I've seen this kind of code in a famous API. Is it better practice to do static_cast<A*>(this);
?