How to call a function from another class

Hello.

I have 2 classes. The first one has in it a getfunction which returns a name
and I am trying to call that function from the second class. The first class
name is PlayerInfo and the getfunction is:

1
2
3
4
string getName()
{
    return name;
} 


And I call that function from the second class with:

cout<<PlayerInfo::getName()<<endl;

but it does not output anything. Is there something I am doing wrong?

And I would get an error at first that said I had to have an
object declared but I don't get an error anymore since I have made the
second class a child class of PlayerInfo.

Last edited on
You can't call a (non-static) member function without an object.
It doesn't make sense to ask "what's your name?" when you're not addressing anyone.
Alright thanks. Will call from main then
It doesn't have anything to do with where you are calling it from.
Topic archived. No new replies allowed.