LNK2019

I feel like I'm missing something simple. I keep getting this error and I cannot figure out what I'm doing wrong.

Error 1 error LNK2019: unresolved external symbol "void __cdecl deposit(double)" (?deposit@@YAXN@Z) referenced in function _main

Error 2 error LNK1120: 1 unresolved externals

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
 #include <iostream>
#include <string>
#include <iomanip>

using namespace std;

void deposit(double);

class BankAccount
{
private:
	int ActNum;
	string LastName;
	string FirstName;
	double balance;
public:
	BankAccount()
	{
		ActNum = 0;
		balance = 0.0;
	}
	BankAccount(int act, string first, string last, double bal)
	{
		ActNum = act;
		FirstName = first;
		LastName = last;
		balance = bal;
	}

	void setLastName(string last)
	{
		LastName = last;
	}

	int getActNum()
	{
		return ActNum;
	}

	string getFirstName()
	{
		return FirstName;
	}

	string getLastName()
	{
		return LastName;
	}

	double getbalance()
	{
		return balance;
	}

	void print()
	{
		cout<<fixed<<showpoint<<setprecision(2);
		cout<<"Account Number: "<<ActNum<<endl;
		cout<<"Name: "<<FirstName<<' '<<LastName<<endl;
		cout<<"Current Balance: $"<<balance<<endl;
	}
	
	void deposit(double money)
	{
		balance = balance + money;
	}

};

int main()
{
	
	BankAccount one(5623, "Jim", "Jones", 100.89);
	one.print();

	double balance = 0.0;
	double money = 0.0;
	cout<<"enter amount of deposit: ";
	cin>>money;
	deposit(money);
	cout<<"Your new balance is: $"<<balance<<endl;

	return 0;
}
I commented your code to let you see where the problems were.
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
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

//void deposit(double);	// don't need this declaration and is causing the error

class BankAccount
{
private:
	int ActNum;
	string LastName;
	string FirstName;
	double balance;
public:
	BankAccount()
	{
		ActNum = 0;
		balance = 0.0;
	}
	BankAccount(int act, string first, string last, double bal)
	{
		ActNum = act;
		FirstName = first;
		LastName = last;
		balance = bal;
	}

	void setLastName(string last)
	{
		LastName = last;
	}

	int getActNum()
	{
		return ActNum;
	}

	string getFirstName()
	{
		return FirstName;
	}

	string getLastName()
	{
		return LastName;
	}

	double getbalance()
	{
		return balance;
	}

	void print()
	{
		cout<<fixed<<showpoint<<setprecision(2);
		cout<<"Account Number: "<<ActNum<<endl;
		cout<<"Name: "<<FirstName<<' '<<LastName<<endl;
		cout<<"Current Balance: $"<<balance<<endl;
	}
	
	void deposit(double money)
	{
		balance = balance + money;		// can also do balance += money;
	}

};

int main()
{
	
	BankAccount one(5623, "Jim", "Jones", 100.89);
	one.print();

	//double balance = 0.0; // don't need this 
	double money = 0.0;
	cout<<"enter amount of deposit: ";
	cin>>money;
	one.deposit(money);		// add class object to front
	//cout<<"Your new balance is: $";          // don't need this for the example
	one.print();		// print out new balance 

	return 0;
}
Account Number: 5623
Name: Jim Jones
Current Balance: $100.89
enter amount of deposit: 100.00
Account Number: 5623
Name: Jim Jones
Current Balance: $200.89
Last edited on
Thank you so much. As usual I was over complicating things. Now hopefully I can get through part 2 of this assignment without issue. Thanks again
Topic archived. No new replies allowed.