Unresolved External Symbol

Hi there, I keep getting an error message Unresolved External Symbol. I have no idea where to go from here. Any suggestions would be great, thank you! The Node.cpp file is my biggest issue. These are the instructions where I am stuck on. 'Assign values to head and tail’s “data” attribute. Then make head “point to” tail. In order to test that head correctly points to tail, use the getNextPtr() function and store the result in nodePtr. Write cout statements to verify the nodePtr is indeed pointing to tail.'

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
70
71
72
73
74
75
76
77
78
79
80
81
//Node.h 
#pragma once

class Node
{
public:
	
	Node(void);
	~Node(void);

	Node(int value);
	void setNextPtr(Node* nextNode);
	Node* getNextPtr() const;
	void setData(int value);
	int getData() const;
	
private:
	int data;
	Node* nextPtr;
	
};

//Node.cpp 

#include "Node.h"

Node::Node(void)
{

}

Node::~Node(void)
{
	
}

Node::Node(int value){
}

void Node::setNextPtr(Node* nextNode){

}

//Node::Node Node* getNextPtr() const{

//}

void Node::setData(int value){

}
int Node::getData() const{

}
	
//main.cpp

#include <iostream>
#include <string>
using namespace std;
#include "Node.h"

void testNodeClass(){
	
	Node head;	
	Node tail;
	
	Node* nodePtr;
	
	head.setData(10);
	tail.setData(20);

	head.setNextPtr(&tail);
	
	nodePtr = head.getNextPtr();
}


int main(){
	testNodeClass();

}
You likely did not link the program correctly. what compiler are you using? In Visual C++ you will need to create a project. In gcc see for example http://matrixprogramming.com/2008/03/compilelink
I'm using Express 2010. It brings up an error about the getNextPtr but I don't know how to declare it in Node.CPP. That link you posted is useless unfortunately. :/
in main function,

you're calling head.getNextPtr(), however, in the .cpp is commented. So, you're calling a function that has not been implemented yet.
I got the code to compile but it is not outtputing what I want. In my last cout statement it is not outputting correctly. Could anyone tell me why? I need to output cout statements to verify the nodePtr is indeed pointing to tail. How do I go about doing this? Thanks in advance!

Here is my updated 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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//main.cpp

#include <iostream>
#include <string>
using namespace std;
#include "Node.h"


void testNodeClass(){
	
	//two node objects
	Node head;	
	Node tail(5);
	
	//declare one node pointer
	Node* nodePtr = &tail;
	
	
	
	head.setData(10);
	tail.setData(20);

	head.setNextPtr(nodePtr);

	cout << head.getNextPtr() << endl;
	

	nodePtr = &head;
	tail.setNextPtr(nodePtr);

	nodePtr = head.getNextPtr();
 
	cout << head.getNextPtr() << endl; 
	
	//-------------------------------------------
	cout << nodePtr->getData() << endl; //pointer
	//-------------------------------------------

	system("pause");

}





int main(){


	testNodeClass();
	
	
	return 0;

	system("pause");

}

//node.cpp
#include "Node.h"

//default 
Node::Node(void)
{
	setData(0);
	setNextPtr(nullptr);
}


Node::~Node(void)
{
}

//2nd constructors
Node::Node(int value){

	setData(value);
	setNextPtr(nullptr);

}



void Node::setNextPtr(Node* nextNode){
	this->nextPtr = nextNode;
}


Node* Node::getNextPtr() const{

	return nextPtr;

}


void Node::setData(int value){
	
	this->data=data;

}

int Node::getData() const{

	return data;

}
	
//node.h
#pragma once


class Node
{
public:

	Node(void);
	~Node(void);
	
	Node(int value);
	void setNextPtr(Node* nextNode);
	Node* getNextPtr() const;
	void setData(int value);
	int getData() const;
	
private:
	int data;
	Node* nextPtr;
};
Topic archived. No new replies allowed.