2012-08-29 23 views
5

私は見ているが、そこに他の回答があることを知っているが、私は何を探しているのか分からないので、これを"再投稿 "として報告しないでください。未解決の外部シンボル "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; 
    } 
} 
} 

私の銀行口座のヘッダファイル

#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; 
} 
} 

マイエラーファイル:あなたは引数を取らないコンストラクタを宣言し、あなたのBankAccountクラスで

1>BankAccountMain.obj : error LNK2019: unresolved external symbol "public: __thiscall BankAccount::BankAccount(void)" ([email protected]@[email protected]) referenced in function "public: __thiscall SavingsAccount::SavingsAccount(void)" ([email protected]@[email protected]) 

1>CheckingAccount.obj : error LNK2001: unresolved external symbol "public: __thiscall BankAccount::BankAccount(void)" ([email protected]@[email protected]) 
+0

これらの種類のエラーが表示されたら、LIBファイルへのリンクを忘れていないことを確認してください。 WinAPIのものでさえ、ヘッダーを追加するだけでは不十分です。 –

答えて

18

「__thiscall」はノイズです。読む。エラーメッセージはBankAccount::BankAccount(void)について不平を言っています。ヘッダファイルには、BankAccountにデフォルトのコンストラクタがありますが、定義はありません。

+0

@MattWestlake - 私は感情を知っています。これらのエラーメッセージには多くの情報がありますが、それらはかなり密集しています。 –

+0

なぜMS Studioはエラーメッセージであまりにも謎めいていますか?なぜ不要なノイズですか? –

+1

@ JavierQuevedo-Fernández - 別のコンテキストでは、「ノイズ」が問題になる可能性があるためです。意味のあるエラーメッセージを生成するためにコンパイラが行うことができるのはあまりありません。良いプログラマになるのは、エラーメッセージを理解することを学ぶことです。 –

4

BankAccount(); 

ただし、実装していません。これがリンカがそれを見つけることができない理由です。 .cppファイルにこのコンストラクターの実装を提供すると、リンクステップが機能するはずです。

+0

私はコードが長すぎるのを見てきました... ugh –

+0

@MattWestlake誰にでも起こります。一般に、リンカーエラーは通常、関数の実装を忘れたか、正しいライブラリにリンクできなかったことを意味します。これらは通常、最初に探すべきものです。 – mathematician1975

関連する問題