Rolling back use of typedef with smart pointers.

This is to reduce the obfuscation of the code.
This commit is contained in:
Ian Dinwoodie
2019-05-18 10:12:01 -04:00
parent 176fe54642
commit 5a4975691f
7 changed files with 37 additions and 48 deletions

View File

@@ -5,7 +5,6 @@
class Door
{
public:
typedef std::shared_ptr<Door> ptr_t;
virtual void open(void) = 0;
virtual void close(void) = 0;
};
@@ -27,7 +26,7 @@ class LabDoor : public Door
class SecuredDoor
{
public:
SecuredDoor(Door::ptr_t door)
SecuredDoor(std::shared_ptr<Door> door)
: door_(door)
{
}
@@ -52,12 +51,12 @@ class SecuredDoor
return password == "Bond007";
}
Door::ptr_t door_;
std::shared_ptr<Door> door_;
};
int main()
{
Door::ptr_t labDoor = std::make_shared<LabDoor>();
std::shared_ptr<Door> labDoor = std::make_shared<LabDoor>();
SecuredDoor securedDoor(labDoor);
securedDoor.open("invalid"); // Output: No way, Jose!