Last active
September 15, 2023 02:43
-
-
Save chomado/32665d773e9daffc4a8b to your computer and use it in GitHub Desktop.
「猫でも分かるC++」写経
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
class Person { | |
string name; | |
int age; | |
char sex; | |
public: | |
Person(const string &nm, int n, char s) : name(nm), age(n), sex(s) {} | |
void show(); | |
}; | |
void Person::show() { | |
cout << "氏名: " << name << endl; | |
cout << "年齢: " << age << " 歳" << endl; | |
cout << "性別: " << sex << endl; | |
} | |
int main() | |
{ | |
Person yamada("ヤマダ", 26, 'M'); | |
Person tanaka("田中", 24, 'F'); | |
yamada.show(); | |
tanaka.show(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
class Person { | |
string name; | |
int age; | |
char sex; | |
public: | |
Person(const string &nm, int n, char s) : name(nm), age(n), sex(s) {} | |
void show(); | |
}; | |
void Person::show() { | |
cout << "氏名: " << name << endl; | |
cout << "年齢: " << age << " 歳" << endl; | |
cout << "性別: " << sex << endl; | |
} | |
int main() | |
{ | |
Person tanaka("田中", 24, 'F'); | |
Person yamada("ヤマダ", 26, 'M'); | |
yamada.show(); | |
tanaka.show(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
class Person { | |
string name; | |
int age; | |
char sex; | |
public: | |
Person(const string &nm, int n, char s) : name(nm), age(n), sex(s) {} | |
void show(); | |
}; | |
void Person::show() { | |
cout << "氏名: " << name << endl; | |
cout << "年齢: " << age << " 歳" << endl; | |
cout << "性別: " << sex << endl; | |
} | |
int main() | |
{ | |
Person chomado("ちょまど",24, 'F'); | |
Person yamada("ヤマダ", 26, 'M'); | |
Person tanaka("田中", 24, 'F'); | |
yamada.show(); | |
tanaka.show(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment