-
Notifications
You must be signed in to change notification settings - Fork 28
/
stock.h
executable file
·81 lines (58 loc) · 2.64 KB
/
stock.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//*****************************************************************************************************
//
// This header file defines a Stock class with overloaded comparison and output operators to
// facilitate easy comparison and display of stock information.
//
//*****************************************************************************************************
#ifndef STOCK_H
#define STOCK_H
//*****************************************************************************************************
#include <string>
//*****************************************************************************************************
class Stock {
private:
std::string companyName;
std::string stockSymbol;
double stockPrice;
friend std::ostream &operator<<(std::ostream &out, const Stock &stock);
public:
Stock(const std::string &name = "", const std::string &symbol = "", double price = 0);
Stock(const Stock &s);
std::string getName() const;
std::string getSymbol() const;
double getPrice() const;
bool operator==(const Stock &rhs) const;
bool operator!=(const Stock &rhs) const;
bool operator>(const Stock &rhs) const;
bool operator<(const Stock &rhs) const;
};
//*****************************************************************************************************
inline std::string Stock::getName() const {
return companyName;
}
//*****************************************************************************************************
inline std::string Stock::getSymbol() const {
return stockSymbol;
}
//*****************************************************************************************************
inline double Stock::getPrice() const {
return stockPrice;
}
//*****************************************************************************************************
inline bool Stock::operator==(const Stock &rhs) const {
return (stockSymbol == rhs.stockSymbol);
}
//*****************************************************************************************************
inline bool Stock::operator!=(const Stock &rhs) const {
return (stockSymbol != rhs.stockSymbol);
}
//*****************************************************************************************************
inline bool Stock::operator>(const Stock &rhs) const {
return (stockSymbol > rhs.stockSymbol);
}
//*****************************************************************************************************
inline bool Stock::operator<(const Stock &rhs) const {
return (stockSymbol < rhs.stockSymbol);
}
//*****************************************************************************************************
#endif