헤더 파일과 호환되지선언 형식
#include "bankAccount.h"
#include <string>
#include <iostream>
using std::string;
string bankAccount::getAcctOwnersName() const
{
return acctOwnersName;
}
int bankAccount::getAcctNum() const
{
return acctNum;
}
double bankAccount::getBalance() const
{
return acctBalance;
}
void bankAccount::setAcctOwnersName(string name)
{
acctOwnersName=name;
}
void bankAccount::setAcctNum(int num)
{
acctNum=num;
}
void bankAccount::setBalance(double b)
{
acctBalance=b;
}
void bankAccount::print() const
{
std::cout << "Name on Account: " << getAcctOwnersName() << std::endl;
std::cout << "Account Id: " << getAcctNum() << std::endl;
std::cout << "Balance: " << getBalance() << std::endl;
}
내가 getAcctOwnersName에서 오류를 얻을 수 있도록하고, setAcctOwnersName이 선언은 "< 오류 -와 호환되지 않는 것을 주장하십시오 type> bankAccount :: getAcctOwnersName() const "를 입력하십시오.
헤더 파일에 ''이 (가) 포함되어 있지 않으므로 코드가 컴파일되어서는 안됩니다. 문제는 헤더가'std :: string'와는 다른'string '의 의미를 가질 것이라고 생각합니다. '#include '을 헤더에 넣고 거기에 일반'string' 대신'std :: string'을 사용하십시오. 도움이되는지 확인하십시오. –
Angew
컴파일러가 표시하는 * 첫 번째 오류가 아니라면 무시하는 것이 가장 좋습니다. 오류 목록을 항상 위에서 아래로 살펴보십시오. 마지막으로 인쇄 할 때 시작하지 마십시오. 출력에서 찾을 수있는 것이 가장 쉽습니다. 종종 프로그램의 한 실수는 나중에 오류의 연쇄를 야기 할 수 있으며 처음부터 오류를 일으키지 않고 나중에 오류를 수정하려고 시도하는 것은 좋지 않습니다. –