Error 4 error LNK1120: 1

I am a C++ beginner and am trying to make a address book program that can write names and phone numbers to a file and then be able to view them later. I am not done the code, I am trying to make an array of classes so that each person can have two fields of info.I have yet to do most of the code, and so far the Void view function is only a test to see if i transferred the array to the function properly. I think it should work but i get two errors when i run it:
Error 4 error LNK1120: 1 unresolved externals C:\Users\Isaac Morton\Documents\Visual Studio 2013\Projects\address book\Debug\address book.exe address book
and:
Error 3 error LNK2019: unresolved external symbol "void __cdecl add(void)" (?add@@YAXXZ) referenced in function _main C:\Users\Isaac Morton\Documents\Visual Studio 2013\Projects\address book\Project42\Source.obj address book


my 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
#include <iostream>
#include <fstream>
#include<string>
using namespace std;

class contact
{
public:
	int phone;
	int addres;
};

int Checkans(string ans);
void add();
void view( contact contactarray[]);
int main()
{
	ofstream myf;
	string ans;
	contact contactarray[10];
	contactarray[0].addres = 3;
	cout << "Do you want to view or add contacts?\n";
	cin >> ans;
	if (Checkans(ans) == 1)
		view( contactarray);
	else if (Checkans(ans) == 2)
		add();
	
	
	system("pause");
}

int Checkans(string ans)
{
	if (ans == "view" || "View")
		return 1;
	else if (ans == "add" || "Add")
		return 2;
}

void view( contact contactarray[])
{
	cout<< contactarray[0].addres;
	system("pause");
}
Hi there !

If you look right here you can see the compiler's hint at what the problem is:
Error 3 error LNK2019: unresolved external symbol "void __cdecl add(void)" (?add@@YAXXZ) referenced in function _main C:\Users\Isaac Morton\Documents\Visual Studio 2013\Projects\address book\Project42\Source.obj address book

Line 14 declares the void add(); but there is no definition.. so the linker throws the error.
Last edited on
Topic archived. No new replies allowed.