Skip to content

Instantly share code, notes, and snippets.

@Reputeless
Last active June 3, 2020 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reputeless/4d91b665876a2b97f2c5f48a2f9baf35 to your computer and use it in GitHub Desktop.
Save Reputeless/4d91b665876a2b97f2c5f48a2f9baf35 to your computer and use it in GitHub Desktop.
// コンストラクタ、デストラクタ練習
# 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