-
-
Save chomado/7c8451a4411774a2467d to your computer and use it in GitHub Desktop.
// doesn't work
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 <string> | |
#include <iostream> | |
class Human { | |
private: | |
std::string full_name; | |
int height; | |
int wight; | |
public: | |
Human(std::string name, int h, int w); // コンストラクタ | |
std::string name() { return full_name; } | |
int get_height() { return height; } | |
int get_weight() { return weight; } | |
void grow_fat(int dw); | |
void slim_off(int dw); | |
}; |
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 <string> | |
#include "a.h" | |
Human::Human(string name, int h, int w) | |
{ | |
full_name = name; | |
height = h; | |
weight = w; | |
} | |
void Human::grow_fat(int dw) | |
{ | |
weight += dw; | |
} | |
void Human::slim_off(int dw) | |
{ | |
weight -= dw; | |
} |
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> | |
#include "a.h" | |
using namespace std; | |
void print_Human(string title, Human *p) | |
{ | |
std::cout << title << p->name() << " " | |
<< p->get_height() << "com " << p->get_weight() << "kg" << std::endl; | |
} | |
int main() | |
{ | |
Human chomado("chomado", 152, 45); | |
chomado.grow_fat(2); | |
print_Human("chomado = ", &chomado); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment