diff options
-rw-r--r-- | 7p15.cpp | 8 | ||||
-rw-r--r-- | 7p16.cpp | 13 | ||||
-rw-r--r-- | 7p17.cpp | 14 | ||||
-rw-r--r-- | 7p18.cpp | 15 | ||||
-rw-r--r-- | 7p19.cpp | 14 | ||||
-rw-r--r-- | person.hpp | 3 |
6 files changed, 66 insertions, 1 deletions
@@ -1,12 +1,18 @@ #include <iostream> +#include "person.hpp" /* * - * Description + * 7.15 * * */ int main () { + + Person p1("John Doe"); + Person p2("Jane Doe", "Street Street 1"); + std::cout << p1.GetName() << " " << p1.GetAddress() << std::endl; + std::cout << p2.GetName() << " " << p2.GetAddress() << std::endl; return 0; } diff --git a/7p16.cpp b/7p16.cpp new file mode 100644 index 0000000..36f2ff1 --- /dev/null +++ b/7p16.cpp @@ -0,0 +1,13 @@ + +/* + * + * 7.16 + * + * + */ + +int main () { + + // It does not really matter if there are no access specifiers or if you choose to have both or only one of them. + return 0; +} diff --git a/7p17.cpp b/7p17.cpp new file mode 100644 index 0000000..6f54eca --- /dev/null +++ b/7p17.cpp @@ -0,0 +1,14 @@ + +/* + * + * 7.17 + * + * + */ + +int main () { + + // class is private by default + // struct is public by default + return 0; +} diff --git a/7p18.cpp b/7p18.cpp new file mode 100644 index 0000000..fa1c047 --- /dev/null +++ b/7p18.cpp @@ -0,0 +1,15 @@ + +/* + * + * 7.18 + * + * + */ + +int main () { + + // We dont need to expose functions and data members that should only be + // accessed or used by the public functions. + // There are some things that the user does not need to know about when using the class. + return 0; +} diff --git a/7p19.cpp b/7p19.cpp new file mode 100644 index 0000000..7622cb4 --- /dev/null +++ b/7p19.cpp @@ -0,0 +1,14 @@ + +/* + * + * 7.19 + * + * + */ + +int main () { + + //Name and Address members should be private + // The rest public + return 0; +} @@ -4,6 +4,9 @@ #include <vector> struct Person { + Person() = default; + Person(const std::string &name): Name(name) {} + Person(const std::string &name, const std::string &addr): Name(name), Address(addr) {} std::string Name; std::string Address; std::string GetAddress() const { return Address; } |