I need to get acces to private data from class info in method "pop" from class stos. I know that I can use a special method modificating nested function, but I think that it isn't elegnat as using "friend". I'd like to make the external method as a friend for nested class, but I'm getting information "cannot overload functions distungished by return type alone". Is it possible to make that?
class stos
{
class info
{
int x;
bool isGood;
friend info pop(); // warning: cannot overload functions distungished by return type alone
};
static const int SIZE = 10;
int dane[SIZE];
bool isEmpty;
bool isFull;
int *top;
public:
stos();
info pop();
info push(int x);
};
EDIT:
stos::info stos::pop()
{
info objInfo;
if (isEmpty == true)
{
objInfo.isGood = false;
return objInfo;
}
objInfo.isGood = true;
objInfo.x = *top;
top--;
return objInfo;
}