Error: Reference to non static function must be called?

So on lines 36 - 39 (The commented out functions) is where I'm sure is causing this error because once I don't comment them out pretty much everywhere Flink or Rlink is used or defined I get this error. Any ideas as to why?


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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef nodes_Nodes_h
#define nodes_Nodes_h
#include <cstdlib>
#include <iostream>
using namespace std;

namespace angeles_1A
{
    class dnode
    {
        public:
            // TYPEDEFS
            typedef double value_type;
            // CONSTRUCTORs
            dnode(const value_type entry = value_type(), dnode *ptr = NULL)
            { data_field = entry; head_ptr = ptr; tail_ptr = NULL; }
            // SETS VALUES
            void set_Flink(dnode *new_Flink)
            { Flink = new_Flink;}
            void set_Rlink(dnode *new_Rlink)
            { Rlink = new_Rlink;}
                    void set_data(const value_type& new_data)
            {data_field = new_data;}
            void set_xy(value_type entry1,value_type entry2)
            {x = entry1; y = entry2;}
            // RETURNS VALUES
            value_type data() const {return data_field;}
            //const dnode *Flink() const {return Flink;}
            //dnode *Flink() {return Flink;}
            //const dnode *Rlink() const {return Rlink;}
            //dnode *Rlink() {return Rlink;}
            // MANIPULATES LINKED LIST
            void list_head_insert(const value_type& entry, dnode*& ptr)
            { head_ptr = new dnode(entry,ptr); }
            void list_insert(dnode* previous_ptr, const value_type& entry)
            {
                dnode *insert_ptr;
            
                insert_ptr = new dnode(entry, previous_ptr->Flink);
                previous_ptr->set_Flink(insert_ptr);
            }
            void print_items(dnode* ptr)
            {
                 dnode* cursor;
                 for(cursor = ptr; cursor != NULL; cursor = cursor->Flink)
                 {
                     if(cursor->data() >= x && cursor->data() >= y)
                          cout << cursor->data_field << " /n";
                 }
            
                 for(cursor = tail_ptr; cursor != head_ptr; cursor = cursor->Rlink)
                 {
                     if(cursor->data() >= y && cursor->data() >= x)
                         cout << cursor->data() << " /n";
                 }
            }
        private:
            value_type data_field, x, y;
            dnode *head_ptr;
            dnode *tail_ptr;
            dnode *Flink;
            dnode *Rlink;
    };
    
    
    
    
}
#endif 


Also here is my main

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
#include <iostream>
#include "Nodes.h"

using namespace angeles_1A;
using namespace std;

int main()
{
    
	dnode *p;
    dnode test;
    p = &test;
    
    // Inserts link at head
    test.list_head_insert(0,p);
    
	// Inserts values into the link list
	for(int i = 0; i < 6; ++i)
	{
		test.list_insert(p, i);
	}
    
    
	test.set_xy(2,5);
    
    test.print_items(p);
    
	return 0;
    
    
}

Do you see what you are doing do not you?

const dnode *Flink() const {return Flink;}
Is the function's name to similar too the private variable? Is that causing it?
Last edited on
closed account (zb0S216C)
A Newbie wrote:
1
2
3
4
//const dnode *Flink() const {return Flink;}
//dnode *Flink() {return Flink;}
//const dnode *Rlink() const {return Rlink;}
//dnode *Rlink() {return Rlink;} 

These functions are the problem as you suspected. What you're doing here is trying to return the address of "Flink" and "Rlink" (yes, functions have addresses in memory). Logic dictates that your error is due to ambiguous symbols. In addition, the compiler will refuse the conversion from a pointer to a member function to a "dnode" pointer.

You need to rename either the data-members or the member functions; common practice is to give data-members a special prefix or suffix so that they are easily identified, like so:

1
2
3
4
5
struct Structure
{
  int MData_Member; // 'M' prefix
  int Data_Member_; // '_' suffix
};

Member functions don't have these naming conventions.

Wazzak
Last edited on
Alright, thanks you two I'm no longer getting that error (Now if only I could get my print_items function to return what I need it to).
Topic archived. No new replies allowed.