6.10 Lab*: Singly-Linked Lists (Park)
Replace Park.hDisplay() with output stream operator
This commit is contained in:
parent
ef6762ad57
commit
4ae56c5a42
@ -97,7 +97,7 @@ void LinkedList::displayList() const {
|
||||
// While pCur points to a node, traverse the list.
|
||||
while (pCur) {
|
||||
// Display the value in this node.
|
||||
pCur->park.hDdisplay();
|
||||
cout << pCur->park << endl;
|
||||
|
||||
// Move to the next node.
|
||||
pCur = pCur->next;
|
||||
|
@ -38,11 +38,12 @@ Park::Park(string cd, string st, string nm, string dsc, int yr) {
|
||||
// Displays the values of a Park object member variables
|
||||
// on one line (horizontal display)
|
||||
// ***********************************************************
|
||||
void Park::hDdisplay() const {
|
||||
cout << code << " ";
|
||||
cout << state << " ";
|
||||
cout << year << " ";
|
||||
cout << name << " " << endl;
|
||||
ostream& operator<<(ostream &out, const Park &park) {
|
||||
out << park.code << " ";
|
||||
out << park.state << " ";
|
||||
out << park.year << " ";
|
||||
out << park.name << " ";
|
||||
return out;
|
||||
}
|
||||
|
||||
// ***********************************************************
|
||||
@ -55,4 +56,3 @@ void Park::vDisplay() const {
|
||||
cout << year << endl;
|
||||
cout << state << endl;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
int getYear() const { return year; }
|
||||
|
||||
//other functions
|
||||
void hDdisplay() const;
|
||||
friend std::ostream &operator<<(std::ostream &, const Park &);
|
||||
|
||||
void vDisplay() const;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user