For example, in Qt (correct me, if logic is wrong, I have not done Qt for a long time), you can do this:
QLabel label = new QLabel(this);
Now let's suppose:
#include <iostream>
class AbstractBase
{
public:
virtual void A() = 0;
};
class DerivedClass : public AbstractBase
{
public:
void A()
{
std::cout << "ClassA";
}
DerivedClass(AbstractBase* Base)
{
A();
}
};
int main()
{
AbstractBase* A = new DerivedClass(this);
}
But the compiler returns: "invalid use of this in non-member function". What is the correct way to add the 'this' parameter in this case? (% of%, why it is derived.) Is this possible (refer to A as the parameter)?