#include <iostream>
using namespace std;
class A
{
public:
void f(){cout<<"arbuz"<<endl;};
};
class SmartPtr
{
public:
A *ptr{nullptr};
A *fTable[5]{nullptr};
int fUse{0};
A *operator->()
{
fTable[fUse] = ptr;
fUse = (++fUse) % 5;
return ptr;
}
A &operator*()
{
return *(operator->());
}
};
int main()
{
A a;
SmartPtr wsk;
wsk=*a;
(*wsk).f();
}
Cześć, mógłby ktoś wytłumaczyć dlaczego w int main() w linice wsk=*a; występuje błąd:
main.cpp:34:9: error: no match for ‘operator*’ (operand type is ‘A’)
34 | wsk=*a;
| ^~