So I am using C++ and experimenting with classes. I am trying to create a function with a class type. Here is the code:
struct action{
void setup(std::string){
/*...*/
}
};
action move(){
setup("*");//<-error:[use of undeclared identifier 'setup']
}
Can the instance function of the class access its member functions and objects? Also, what should it return? Do i have to create a seperate action instance to return? Can it be related to the action move
?Thanks!
For starters the function setup
is a non-static member function of the class action
. It can be used applied to an object of the class. And the function move
returns nothing though it has the return type action
.
The function move
can look like
action move()
{
action a;
a.setup("*");
return a;
}