-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashableObject.h
More file actions
46 lines (38 loc) · 1.62 KB
/
Copy pathHashableObject.h
File metadata and controls
46 lines (38 loc) · 1.62 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Blake Berry
// 03/08/2022
// Homework 4
// This file is an interface for the HashableObject class. This class is an
// abstract base class definig the necessary functionality of a hashable obj.
// The class includes a string key and leaves the derived classes to assign
// a value associated with a string key. The hashable object should be able to
// generate its own hash and return both the key and value.
//------------------------------------------------------------------------------
// use key instead of id
#pragma once
#include <string>
class HashableObject
{
private:
std::string id_; // the string id held by the hashable object
public:
//-------------------------- Constructor -----------------------------------
// Frees any dynamic memory associated with the HashableObject
// Postconditions: The hashable Object is freed of any dynamic memory
HashableObject(std::string id = "") : id_(id) {};
//-------------------------- destructor -----------------------------------
// Frees any dynamic memory associated with the HashableObject
// Postconditions: The hashable Object is freed of any dynamic memory
virtual ~HashableObject() {};
//-------------------------------- getID ----------------------------------
// returns the held string ID
// Postconditions: the string ID is returned
std::string getID() const {
return id_;
}
//------------------------------- setID -----------------------------------
// sets the hashable objects ID to that of the string passed in
// Postconditions: the hashable object ID is set
void setID(std::string id) {
id_ = id;
}
};