Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string>
- using namespace std;
- class Person
- {
- private:
- string m_first;
- string m_last;
- int m_age;
- public:
- // mutator
- void SetFirstName(const string first) { m_first = first; } // const parameters
- void SetLastName(const string last) { m_last = last; }
- void SetAge(const int age) { m_age = age; }
- // accessor
- string GetFirstName() const { return m_first; } // const functions
- string GetLastName() const { return m_last; }
- int GetAge() const { return m_age; }
- // other methods
- void Display() const
- {
- cout << GetFirstName() + " " + GetLastName() << "\n";
- }
- };
- int main()
- {
- Person p;
- p.SetFirstName("Ryan");
- p.SetLastName("Appel");
- p.SetAge(35);
- p.Display();
- const int DAYS_IN_WEEK = 7; // const variable
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement