forked from Mooophy/Cpp-Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
122 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// ex13_18.cpp | ||
// Exercise 13.18 | ||
// | ||
// Created by pezy on 1/15/15. | ||
// Copyright (c) 2015 pezy. All rights reserved. | ||
// | ||
// Define an Employee class that contains an employee name and a unique employee identifier. | ||
// Give the class a default constructor and a constructor that | ||
// takes a string representing the employee’s name. | ||
// Each constructor should generate a unique ID by incrementing a static data member. | ||
// | ||
|
||
#include "ex13_18.h" | ||
|
||
int Employee::s_increment = 0; | ||
|
||
Employee::Employee() { | ||
id_ = s_increment++; | ||
} | ||
|
||
Employee::Employee(const string &name) { | ||
id_ = s_increment++; | ||
name_ = name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// ex13_18.h | ||
// Exercise 13.18 | ||
// | ||
// Created by pezy on 1/15/15. | ||
// Copyright (c) 2015 pezy. All rights reserved. | ||
// | ||
// Define an Employee class that contains an employee name and a unique employee identifier. | ||
// Give the class a default constructor and a constructor that | ||
// takes a string representing the employee’s name. | ||
// Each constructor should generate a unique ID by incrementing a static data member. | ||
// | ||
|
||
#ifndef CP5_ex13_18_h | ||
#define CP5_ex13_18_h | ||
|
||
#include <string> | ||
using std::string; | ||
|
||
class Employee { | ||
public: | ||
Employee(); | ||
Employee(const string &name); | ||
|
||
const int id() const { return id_; } | ||
|
||
private: | ||
string name_; | ||
int id_; | ||
static int s_increment; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.