-
-
Save Reputeless/4d91b665876a2b97f2c5f48a2f9baf35 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
// コンストラクタ、デストラクタ練習 | |
# include <iostream> | |
# include <string> | |
class Object | |
{ | |
private: | |
std::string m_name; | |
public: | |
Object() | |
{ | |
std::cout << "Object::Object()\n"; | |
} | |
explicit Object(const std::string& name) | |
: m_name(name) | |
{ | |
std::cout << "Object::Object(const std::string&)\n"; | |
} | |
~Object() | |
{ | |
std::cout << "Dtr(" << m_name << ")\n"; | |
} | |
}; | |
int main() | |
{ | |
Object objA("A"); | |
Object objB("B"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment