Created
November 16, 2013 11:20
-
-
Save Getaji/7499065 to your computer and use it in GitHub Desktop.
テンプレートについて忘れないようにメモ。
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
import std.stdio; | |
template Temp() | |
{ | |
private: | |
string name_; | |
public: | |
string name() { return name_; } | |
this(string name) { name_ = name; } | |
} | |
class Person | |
{ | |
mixin Temp; | |
public: | |
@property | |
{ | |
string name() const { return name_; } | |
void say() const { writeln("Hello, I am ", name_, "!"); } | |
} | |
} | |
class Enemy | |
{ | |
mixin Temp; | |
public: | |
void shout() const { writeln("I am ", name_, "! I'm kill you!!"); } | |
} | |
int main(string[] argv) | |
{ | |
auto getaji = new Person("Getaji"); | |
auto slime = new Enemy("Slime"); | |
writeln("Name:", getaji.name); | |
getaji.say; | |
slime.shout(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment