Last active
May 30, 2018 20:53
-
-
Save drodil/141a073c986e745ddeca5cb5a952b1ae to your computer and use it in GitHub Desktop.
Copy constructor derp
This file contains hidden or 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> | |
class CarDoor { | |
public: | |
explicit CarDoor(const std::string& name) : mName(name) { } | |
~CarDoor() = default; | |
// Let's imagine a lot of functions here | |
// Copy constructor | |
CarDoor(const CarDoor& other) : mName(other.mName) { } | |
// Copy assignment operator | |
CarDoor& operator=(const CarDoor& other) { | |
mName = other.mName; | |
return *this; | |
} | |
private: | |
std::string mName; | |
}; |
This file contains hidden or 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> | |
class CarDoor { | |
public: | |
CarDoor(const std::string& name, std::uint16_t numWindows) : mName(name), mNumWindows(numWindows) { } | |
~CarDoor() = default; | |
// Let's imagine a lot of functions here | |
// Copy constructor | |
CarDoor(const CarDoor& other) : mName(other.mName) { } | |
// Copy assignment operator | |
CarDoor& operator=(const CarDoor& other) { | |
mName = other.mName; | |
return *this; | |
} | |
private: | |
std::string mName; | |
// WE NEED NEW MEMBER VARIABLE TO CHECK HOW MANY WINDOWS THIS DOOR HAS | |
std::uint8_t mNumWindows | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment