我有這個代碼「for」一家銀行。它按照日期和個人信息的兩種結構進行組織。關於銀行賬戶的信息被組織在一個班級中。我需要用預定義的參數編寫一個默認構造函數。該類包含一個struct類型的數據成員,我不知道如何初始化struct類型的數據成員。這是我的代碼。類型成員的默認構造函數的默認參數struct
struct Date {
int day, month, year;
};
struct Person {
char name[20];
char surname[20];
int IDnum[13];
Date dateBirth;
};
class BankAccount {
public:
BankAccount(????Person p????, int s = 0, bool em = true, int sal = 0) {
??sth for Person p I guess??
sum = s;
employed = em;
salary = sal;
}
private:
Person person;
int sum;
bool employed;
int salary;
};
我希望每一個幫助。提前致謝。
相關/ dupe:https://stackoverflow.com/questions/15307954/default-value-for-struct-parameter – NathanOliver
是的,我看到這篇文章,但我沒有覺得它有幫助,因爲我不明白它。結構中的構造函數? – Winston
C++中'struct'和'class'的區別只是默認可見性:'public' vs'private'。 – Jarod42