Hello there, I've study C++ for a while now and encountered this problem when I was doing my exercises.
Basically I have class Data like so
1 2 3 4 5 6 7 8 9 10
class Data
{
protected:
int number;
double *x; //array contain "number" amount of items
public:
void setX(int, double);//set the individual x values
double getX(int);//get the value of x
double *getX(); //get a pointer to x values
}
double Data:: *getX()
{
return x;
//it gave me error "x is not declared in this scope"
//and when I try this
return &getX;
//it says otherwise
//"error: cannot convert 'double Data::* (*)()' to 'double Data::*' in return|"
//or like this
return Data::getX;
//"error: cannot resolve overloaded function 'getX' based on conversion to type 'double Data::*'|"
}
I'm not allowed to change the function's name or modify the class Data
Is there any thing I misunderstood or mistakes I made?