request for member ... which is of non-class type ...

Hi,I have a problem with an access to other class. There is the code:
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
class Dict_Node
{
  public:
    Dict_Node* parent ;
    char letter ;
    Dict_Node* children[26] ; 
    int childNum ;
	linklist* synonyms;
	
  public:
    Dict_Node()

    {

      parent = NULL ;
      letter = '#' ;
      childNum = 0 ;
      for(int i=0 ; i<26 ; i++)
        children[i] = NULL ;
	  synonyms = NULL;	
    }


}; 

main()
{
  Dict_Node* x;
  cout<<x.letter<<endl;
}



And compiler says :
request for member ‘letter’ in ‘x’, which is of non-class type ‘Dict_Node*’


What can be the problem here? Thank you
You declare a Dict_Node pointer called "x", yet use it as if it were an actual object. Either declare it as an object (by removing the '*' in the declaration) or dereference it as a pointer (using '->' instead of '.' to access functions/variables). If you declare it as a pointer, you will have to either dynamically allocate it using new or assign it to the address of an existing object.
Topic archived. No new replies allowed.