안녕하세요 여러분, 저는 OOP와 C++에 대해 처음 보았습니다.'newacc'는 클래스 또는 이름 공간이 아닙니다.
나는 클래스를 정의하려고하는데, 그것의 함수이고, 그것들을 사용한다. 나는 내가 지금까지 가지고있는 것과 내가 어디서 오류를 겪고 있는지를 보여줄 것이다. 라는 파일에서
"account.h는"내가 가진 :라는 파일에
#include <iostream>
#include <string>
using namespace std;
class Account{
string fname;
string lname;
string sinnum;
string accttype;
int numtrans;
double balance;
public:
Account(string,string,string,string);
double DepositAmt(double);
double WithdrawAmt(double);
void PrintStatement();
void getFinalBalance();
};
"account.cpp"나는이 :
Account::Account(string firstname, string lastname, string sinnumber, string acc
{
fname = firstname;
lname = lastname;
sinnum = sinnumber;
accttype = accounttype;
numtrans = 0;
balance = 0;
}
double Account::DepositAmt(double deposit)
{
balance = balance + deposit;
return balance;
}
double Account::WithdrawAmt(double withdraw)
{
balance = balance - withdraw;
return balance;
}
void Account::PrintStatement()
{
cout << "First Name: " << fname << endl;
cout << "Last Name: " << lname << endl;
cout << "SIN: " << sinnum << endl;
cout << "Account Type: " << accttype << endl;
cout << "Total Transactions: " << numtrans << endl;
cout << "Final balance: $" << balance << endl;
}
void Account::getFinalBalance()
{
cout << "Your Final balance is: $" << balance << endl;
}
그리고 마지막으로 나의 마지막 파일에서 호출 " ass2012.cpp "가지고 있어요 :
#include "account.h"
#include "account.cpp"
int main()
{
string fname, lname, sinnum, accttype;
int tempaccttype;
cout << "\nPlease enter your last name: " << endl;
cin >> lname;
cout << "\nPlease enter your SIN number: " << endl;
cin >> sinnum;
cout << "\nPlease choose your account type: "<< endl;
cout << "1: Checking" << endl;
cout << "2: Savings" << endl;
cin >> tempaccttype;
if (tempaccttype == 1)
{
accttype = "Checking";
}
else
{
accttype = "Savings";
}
Account newacc (fname, lname, sinnum, accttype); // HERE IS WHERE I GET THE ERROR
newacc::getFinalStatement();
return 0;
}
내가 뭘 잘못하고 있는지 말해 줄 수 있어요 !!
편집 : 감사합니다. Naveen !! 저를 벽에 태우는 것은 항상 작은 것들입니다.