Q:

c++ linux access an object from a method

HI,
How can I define an object in a method?
std::string method(std::string name, &pointer_to_any_class)
{
//code
}?

if I have a Class like Class *x= new Class(); 
Can i have method like Method("me",*x);?
Class_me *y= new Class_me(); 
method("hey",*y);//will this mean that &pointer_to_any_class is a pointer to Class_me?

A:

If Class_me is derived from Class then it will work:
class Class
{
    ...
}

class Class_me : public Class
{
    ...
}

std::string method(const std::string &name, Class *cls)
{
    ...
}

Class *x = new Class();
Class_me *y = new Class_me();

method("me", x);
method("hey", y);

