-1
大家好即时通讯新的节目,所以借口noob问题...我 想尽方法与不确定refernce错误打通,但它不断抛出的错误我 我尝试使用指针“ - >”和“::”符号以及点“。”。 我该怎么办?为什么不能编译?未定义引用错误++动态成员
这是我的CPP文件:
#include <cstdlib>
#include "account.hpp"
using namespace std;
int Account::getAccountNumber()
{
return accountNumber;
}
double Account::getBalance()
{
return balance;
}
void Account::createAccount(LinkedList<Account>& accountsList, string name, int idNumber)
{
...
case 1:
accountsList.addFront(newAcc); //Where the error occurs.
break;
case 2:
do
{
cout << "\n\tWhich position would you like to insert the\n"
<< "\tnew account into?\n"
<< "\tPosition number: #";
cin >> target;
if (cin.fail())
{
cin.clear();
cin.ignore(20,'\n');
cout << "\n\n\tSorry, wrong input. Please enter a correct position.\n\n";
system("pause");
}
}
while(cin.fail());
accountsList.addMiddle(newAcc, target); //and here
break;
case 3:
accountsList.addEnd(newAcc); //and here
break;
}
cout << "\n\n\tAccount Created Successfully\n\n"
<< accountsList;
system("pause");
}
,这里是我的.HPP
#ifndef ACCOUNT_HPP_INCLUDED
#define ACCOUNT_HPP_INCLUDED
#include "linkedlist.hpp"
#include "generic.hpp"
class Account : public GenericAccount
{
int accountNumber;
double balance;
public:
Account(string name = "empty", int idNumber = 0, int accountNumber = 0, double balance = 0)
: GenericAccount(name, idNumber), accountNumber(accountNumber), balance(balance) {}
int getAccountNumber();
double getBalance();
void createAccount(LinkedList<Account>&, string, int);
void deposit(LinkedList<Account>&, Account&);
void withdraw(LinkedList<Account>&, Account&);
void displayAccount(LinkedList<Account>&, Account&);
void deleteAccount(LinkedList<Account>&);
friend istream& operator>> (istream& is, Account& x)
{
is >> x.accountNumber;
return is;
}
friend ostream& operator << (ostream& os, Account& c)
{
os << "Account Number= " << c.getAccountNumber() << "\t"
<< "Balance= "<< c.getBalance() << endl;
return os;
}
friend bool operator == (Account& a, Account& target)
{
return (a.getAccountNumber() == target.getAccountNumber());
}
};
#endif // ACCOUNT_HPP_INCLUDED
整个项目可refernce 下载HERE谢谢大家前进!
[什么是未定义的引用/未解析的外部符号错误,以及如何解决它?](http:/ /stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-doi-i-fix) –
它是'my.hpp'还是'account.hpp '因为你已经在my.ccp中包含后者 –
@gx_感谢您的链接我已经在我的搜索过程中检查出来 – user2657029