10-1
#pragma once #include <string> #ifndef ACCOUNT_H_ #define ACCOUNT_H_ class Account { private: char names[20]; char accounts[20]; double deposits; public: Account(char namec[],char accountc[],double depositc); ~Account(); void display(); void store(double n); void getout(double n); }; #endif // !ACCOUNT_H_ #include "pch.h" #include "account.h" #include <iostream> #include <cstring> using namespace std; Account::Account(char namec[],char accountc[],double depositc) { strcpy_s(names, namec); strcpy_s(accounts, accountc); deposits = depositc; } Account::~Account() { } void Account::display() { cout << names << ": " << accounts << "---" << deposits << endl; } void Account::store(double n) { deposits += n; } void Account::getout(double n) { deposits -= n; } #include "pch.h" #include <iostream> #include "account.h" using namespace std; int main(void) { char namec[20]; char accountc[20]; double depositc; cin >> namec; cin >> accountc; cin >> depositc; Account lls(namec, accountc,depositc); lls.display(); lls.store(100.0); lls.display(); lls.getout(20.0); lls.display(); return 0; }
10-2
#pragma once #ifndef Person_H_ #define Person_H_ using namespace std; class Person { private: static const int LIMIT = 25; string lname; char fname[LIMIT]; public: Person() { lname = ""; fname[0] = '