未解析的外部符号"公共:__thiscall
unresolved external symbol "public: __thiscall
我看过,我知道还有其他答案,但似乎没有一个能告诉我我在寻找什么,所以请不要将其报告为"转发"
我在C++代码中遇到了未解决的外部符号"public:__thiscall"错误,我正要把它踢出窗口,让我的C++类失败。请帮帮我!!!!
我的支票账户头文件
#include "BankAccount.h"
class CheckingAccount
{
private:
int numOfWithdrawls;
double serviceFee;
int AccountBal;
public:
bool withdraw (double wAmmt);
BankAccount CA;
CheckingAccount();
CheckingAccount(int accountNum);
};
及其CPP文件
#include <iostream>
using namespace std;
#include "CheckingAccount.h"
CheckingAccount::CheckingAccount()
{
CA;
numOfWithdrawls = 0;
serviceFee = .50;
}
CheckingAccount::CheckingAccount(int accountNum)
{
CA.setAcctNum (accountNum);
numOfWithdrawls = 0;
serviceFee = .50;
}
bool CheckingAccount::withdraw (double wAmmt)
{
numOfWithdrawls++;
if (numOfWithdrawls < 3)
{
CA.withdraw(wAmmt);
}
else
{
if (CA.getAcctBal() + .50 <=0)
{
return 0;
}
else
{
CA.withdraw(wAmmt + .50);
return 1;
}
}
}
我的BankAccount头文件
#ifndef BankAccount_h
#define BankAccount_h
class BankAccount
{
private:
int acctNum;
double acctBal;
public:
BankAccount();
BankAccount(int AccountNumber);
bool setAcctNum(int aNum);
int getAcctNum();
double getAcctBal();
bool deposit(double dAmmt);
bool withdraw(double wAmmt);
};
#endif
我的银行账户CPP文件
#include <iostream>
using namespace std;
#include "BankAccount.h"
BankAccount::BankAccount(int AccoutNumber)
{
acctNum = 00000;
acctBal = 100.00;
}
bool BankAccount::setAcctNum(int aNum)
{
acctNum = aNum;
return true;
}
int BankAccount::getAcctNum()
{
return acctNum;
}
double BankAccount::getAcctBal()
{
return acctBal;
}
bool BankAccount::deposit(double dAmmt)
{
acctBal += dAmmt;
return true;
}
bool BankAccount::withdraw(double wAmmt)
{
if (acctBal - wAmmt <0)
{
return 0;
}
else
{
acctBal -= wAmmt;
return 1;
}
}
我的错误:
1>BankAccountMain.obj : error LNK2019: unresolved external symbol "public: __thiscall BankAccount::BankAccount(void)" (??0BankAccount@@QAE@XZ) referenced in function "public: __thiscall SavingsAccount::SavingsAccount(void)" (??0SavingsAccount@@QAE@XZ)
1>CheckingAccount.obj : error LNK2001: unresolved external symbol "public: __thiscall BankAccount::BankAccount(void)" (??0BankAccount@@QAE@XZ)
"__thiscall"是噪声。继续阅读。错误消息抱怨BankAccount::BankAccount(void)
。头文件说BankAccount
有一个默认的构造函数,但没有定义
在BankAccount类中,您声明了一个不带参数的构造函数
BankAccount();
但您没有实现它。这就是链接器找不到它的原因。在.cpp文件中提供此构造函数的实现,链接步骤应该可以工作。
相关文章:
- c++库的公共头文件中应该包含什么
- 将公共但非静态的成员函数与ALGLIB集成
- C++从另一个类访问公共静态向量的正确方法是什么
- 如何找到2个单链表的公共节点
- 将地址分配给本地指针后,公共对象的变量将消失
- 公共与私人继承
- 如何从另一个文件继承私有成员变量和公共函数
- 如何从子成员函数修改父公共成员变量
- 为C++03编译器编写部分unique_ptr,该编译器与较新的编译器在公共代码库上运行
- 如何处理从一个对象传递到另一个在C++中具有公共抽象类的对象的消息
- 最长的公共子序列自上而下
- Qt:从另一个窗口访问公共对象
- 常量公共成员有什么问题?
- A类的定义需要B类的定义,如何在不公开B的定义的情况下公开A的公共函数?
- 没有公共构造函数作为另一个类模板成员的类模板
- 父类的私有函数会导致对具有相同名称和相似参数的子类中的公共函数的不明确调用
- 公共/私有/受保护是否会更改内存中结构的排列?
- 我已经建立了递归关系,它找到了两个字符串之间最长的连续公共字符串,我怎么能跳过其中一个字符串中的一个字符
- 使公共数据成员在C++中无法访问
- 为什么C++需要公共继承,忽略朋友声明,才能使动态向下工作?