I am writing member functions for a Stack
class. I have a linked list (LL
) nested-class as a member of the Stack
class. In the Stack
constructor, I instantiate a new linked list which calls the LL
constructor. Using the LL
's member functions I generate a new node and point it at the 1st stack. This resolves fine.
However, when I am coding a Stack
member function eclipse no longer resolves the LL
instance generated in the Stack
constructor nor the LL
member function that I am trying to call.
I have tried switching the nested class between private
and public
member designations. I also tried to connect the nested-class (LL
) with it enclosing/parent class (Stack
) by making the enclosing class a member of the nested class like in the previous question/response:
Nested Class member function can't access function of enclosing class. Why?
Neither have had an effect
No problems here:
class Stack
{
private:
int height, top_element;
class LL
{
push_front(string* new_address)
{
// ... definition
}
//... more nested-class members
};
public:
Stack(); // constructor
void push(string); // enclosing class member
};
Stack
constructor is fine as well:
Stack::Stack(int size)
{
height = size;
top_element = 0;
string stack[height];
LL stack_map;
stack_map.push_front(stack);
}
When I get here I encounter my problem:
void Stack::push(string data)
{
if (top_element == height - 1)
{
string stack[height];
stack_map.push_front(stack); // <- PROBLEM
}
}
I hope I did not include too much code. The second block is the demonstrate that the constructor instantiated the LL
and called push_front()
no problem while the very next definition complained about the same function and couldn't recognize the instantiated LL
, stack_map
stack_map
and push_front
are both underlined in red
Symbol 'stack_map' could not be resolved
and
Method 'push_front' could not be resolved
Aucun commentaire:
Enregistrer un commentaire