Topic: Help needed regarding friend !


Author: hsssed@jabba (BELDONA, SRINATH)
Date: Wed, 29 Dec 1993 10:48:00 GMT
Raw View
Hello world,
 I have a little experiance in C++. I have the following problem.

I have a class called GTS which is a derived class TAB. GTS contains a private
member as
  symbol* stack[STACK_SIZE]; and int sppointer which serves

as an index into the stack.

TAB is an abstract class.

class TAB {
  symbol* stack[STACK_SIZE];
  int sppointer;
   };

class GTS : public TAB {

   private :
    symbol* stack[STACK_SIZE];
    int sppointer;
    friend class list;
   public:
    void set_stack();
    void update_stack();
    void update_abc();
   };

The friend class looks like this.

class list {
  public:
   void set_stack();
   void update_stack();
    };

The function set_stack() in GTS will call the function set_stack() of list
which sets the sppointer of GTS to say e.g 99.

Then the function update_abc() of GTS  will create an object say PQR and
puts the address of PQR onto the stack. So it is supposed to put the
address in stack[99], but when I check for the sppointer value it was
showing 0, though it was set to 99 by the friend list.

I am not able to trace the problem.

Could any one help me, please ?

Thanks,
Nagaraj.

E-mail address : nkumar%hss@lando.hns.com