classes c++

this is my header file.. sorted_list.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
1
2
3
4
sorted_list a;

a.insert(j,i);


in the implementation file sorted_list.cc

1
2
3
4
5
6
7
8
9
10
11
12
13
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...??
Topic archived. No new replies allowed.