Skip to content

Instantly share code, notes, and snippets.

@chomado
Last active September 15, 2023 02:43
Show Gist options
  • Save chomado/32665d773e9daffc4a8b to your computer and use it in GitHub Desktop.
Save chomado/32665d773e9daffc4a8b to your computer and use it in GitHub Desktop.
「猫でも分かるC++」写経
#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;
}
#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;
}
#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