Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- class Warlock {
- public:
- Warlock(std::string name, std::string title) : m_name(name), m_title(title) {
- std::cout << m_name << ": This looks like another boring day.\n";
- }
- Warlock(const Warlock&) = delete;
- Warlock& operator=(const Warlock&) = delete;
- const std::string& getName() const { return m_name; }
- const std::string& getTitle() const { return m_title; }
- void setTitle(const std::string& title) { m_title = title; }
- void introduce() const {
- std::cout << m_name << ": I am " << m_name << ", " << m_title << "!\n";
- }
- ~Warlock() {
- std::cout << m_name << ": My job here is done!\n";
- }
- private:
- std::string m_name;
- std::string m_title;
- };
- int main() {
- // This will not compile
- // Warlock bob;
- Warlock bob("Bob", "the magnificent");
- Warlock jim("Jim", "the nauseating");
- // This will not compile
- // bob = jim;
- // This will not compile
- // Warlock jack(jim);
- bob.introduce();
- jim.introduce();
- bob.setTitle("the wizard");
- jim.setTitle("the destroyer");
- bob.introduce();
- jim.introduce();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement