this is my header file.. sorted_list.h
class sorted_list
{
private:
class list_link
{
private:
int key; // identifies the data
double value; // the data stored
class list_link* next; // a pointer to the next data
public:
list_link(int,double,list_link*);
~list_link();
};
class list_link* first;
public:
sorted_list();
~sorted_list();
void insert(int key, double value);
void remove(int key);
void copy();
class my_iterator
{
private:
class list_link* current; // a pointer to the "current" list element
public:
class my_iterator list_begin();
class my_iterator list_end();
bool iterator_end(class my_iterator* i);
class my_iterator iterator_next(class my_iterator* i);
int iterator_get_key(class my_iterator* i);
double iterator_get_value(class my_iterator* i);
};
};
i tried to access the private variables of list_link through list_link(int,double,list_link*); constructor the compiler is giving me an error...
in the main file
sorted_list a;
a.insert(j,i);
in the implementation file sorted_list.cc
sorted_list::list_link::list_link(int key, double value,list_link* next=0)
{
this->key=key;
this->value=value;
this->next=next;
}
void sorted_list::insert(int key, double value)
{
sorted_list::list_link *temp,*current;
temp=new list_link(key,value);
temp->key;(it is giving me an error here saying that list is a private variable)
}
how can i access the private variables of an inner class...??