hello i am getting two errors.

hey guys i need some help with this code. i am getting two errors. They are both the same saying source file cannot open Account.h. I know this is probably something simple, but i am new to all this and just wanted some help. Thank you. code is posted below.
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
  //Account.h
#include<iostream>
using namespace std;

class Account
{
private:
	double balance = 0;

public:
	Account();
	Account(double);

 double getBalance() const;					//The get balance returns the current balance.
	void deposit(double amount);


	void withdraw(double amount);			//This line is for withdrawing a specified amount. 
	void addInterest(double interestRate);	//This line is for adding interest to the account.

};

//Account.cpp
#include<iostream>
#include "Account.h"
using namespace std;

Account::Account()
{
	double balance = 0;
	balance = 0;
}
double Account::getBalance() const
{
	return balance;
}
void Account::deposit(double amount)
{
	balance += amount;
}

void Account::withdraw(double amount)
{
	balance -= amount;
}

void Account::addInterest(double interestRate)
{
	balance = balance*(1 + interestRate);
}

//Lab7.cpp
#include<iostream>
using namespace std;
#include "Account.h"
int main()
{
	Account		a1;
	Account	a2(500);
	a1.deposit(200);
	a2.withdraw(50);
	a1.addInterest(0.2);
	cout << a1.getBalance();
	cout << "\n";
	cout << a2.getBalance();
	system("pause");
	return 0;
}






Are you sure that "Account.h" exists in the directory that your compiler expects and that you didn't misspell the file name? And remember C++ is case sensitive.

Also your include file should have include guards to prevent multiple inclusions.
These are the directions i was given.



The exercise for this week is to write a class that simulates managing a simple bank account. The account is
created with an initial balance. It is possible to deposit and withdraw funds, to add interest, and to find out the
current balance. This should be implemented in class named Account that includes:
• A default constructor that sets the initial balance to zero.
• A constructor that accepts the initial balance as a parameter.
• A function getBalance that returns the current balance.
• A method deposit for depositing a specified amount.
• A method withdraw for withdrawing a specified amount.
• A method addInterest for adding interest to the account.
The addInterest method takes the interest rate as a parameter and changes the balance in the account to
balance*(1+interestRate).
The UML diagram for the Account class is shown in figure 1.
-balance: double
+Account();
+Account(double);
+double getBalance();
+void deposit(double );
+void withdraw(double);
+void addInterest(double);
Account
Figure 1: The Account Class
Your class must work with the code given below and display the output .
240
450
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Lab7.cpp (main)
#include<iostream>
using namespace std;
#include "Account.h"
int main()
{
			Account		a1;
			Account	a2(500);
			a1.depost(200);
			a2.withdraw(50);
			a1.addInterest(0.2);
cout<<a1.getBalance();
cout<<"\n";
cout<<a2.getBalance();
system("pause");
return 0;
}
The preprocessor itself doesn't care about #include case, but the underlying OS may.
so i need to take the Account.h out?
i figured out what i was doing but now i am getting error saying unresolved external symbol for line 1 in Lab7.cpp.
closed account (48T7M4Gy)
:)
Last edited on
okay i put that but i am still getting the unresolved external symbol error.
closed account (48T7M4Gy)
:)
Last edited on
closed account (48T7M4Gy)
:)
Last edited on
could you explain in detail a little more so that i understand this better.
closed account (48T7M4Gy)
:)

Last edited on
somewhat. i know the constructor does not return a value correct?
closed account (48T7M4Gy)
:)
Last edited on
i understand a little, but still a little confused.
Topic archived. No new replies allowed.