I am not able to access member function using pointer.Find the below code and Error message The Error message is mentioned here error: request for member ‘getstream’ in ‘* objA.A::getfunction()’, which is of non-class type ‘int’ ret = objA.getfunction()->getstream();
#include <iostream>
using namespace std;
class A {
public:
int *getfunction();
int getstream();
};
int* A::getfunction()
{
static int a;
a= getstream();
return &a;
}
int getstream()
{
return 1;
}
int main()
{
int *ret;
A objA;
ret = objA.getfunction()->getstream();
cout << ret;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire