-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototype.cpp
More file actions
31 lines (23 loc) · 785 Bytes
/
prototype.cpp
File metadata and controls
31 lines (23 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <string>
class Sheep {
private:
std::string m_Name;
std::string m_Category;
public:
Sheep(const std::string &name, const std::string &category = "Mountain Sheep")
: m_Name(name), m_Category(category) {}
void setName(std::string name) { m_Name = name; }
std::string getName(void) const { return m_Name; }
void setCategory(std::string category) { m_Name = category; }
std::string getCategory(void) const { return m_Category; }
};
int main(void) {
auto original = Sheep("Jolly");
std::cout << original.getName() << std::endl;
std::cout << original.getCategory() << std::endl;
auto clone = original;
clone.setName("Dolly");
std::cout << clone.getName() << std::endl;
std::cout << clone.getCategory() << std::endl;
}