The "unresolved external symbol" error you are experiencing is most likely due to you having selected an incorrect project template when you created your project. You may alleviate this by doing one of the following:
1.) Copy your code, create a new "Win32 console application" project, paste your code.
or
2.)
a.) Right-click your project's name in the solution explorer.
b.) Select "Properties"
c.) Navigate to "Linker > System"
d.) Make sure the "Configuration" drop-down menu at the top left corner says "Debug"
e.) Click on the "Subsystem" field, a drop-down menu should appear
f.) Select "Console (/SUBSYSTEM:CONSOLE)"
g.) Click "Apply"
h.) Now change the "Configuration" drop-down menu at the top left corner from "Debug" to "Release"
i.) Perform steps e.) through g.)
j.) Click "OK"
This will reconfigure your project, and lift the "unresolved external symbol" error.
I haven't really looked at your code, but you'll want to change some code in your main function. Here's what you've written:
1 2 3 4 5 6 7 8
|
int main()
{
account bankaccount;
bankaccount.getbalance(10000);
cout << "You're balance is" << bankaccount.getBalance;
}
|
1.) On line 3 you instantiate an 'account' object, however, 'account' has no default constructor. The only constructor that exists for 'account' is one that expects a
double
argument, so either give the 'account' class a default constructor, or pass a double to bankaccount's constructor on line 3 of your main function (or both).
2.) Line 5 has the most problems. Your class 'bankaccount' doesn't have a member function named 'getbalance'. It does, however, have one named 'getBalance'. C++ is case-sensitive.
Additionally, 'getBalance' doesn't take any arguments, but you're passing the integer 10000 to it. Remove the argument.
Finally, you're not doing anything with the result that this function returns. You'll have to assign this value to some variable. This change will also have to be reflected in line 6 where you print the balance.
1 2 3 4 5 6 7 8
|
int main()
{
account bankaccount(500.0);
double balance = bankaccount.getBalance();
cout << "Your balance is" << balance;
}
|