(Solved) : 8 Implement Dots Class Shown Represents String Zero Dots E Periods Example Dots D 4 Would Q43975322 . . .





8. Implement the Dots class shown below that represents a string of zero or more dots (i.e. periods). For example Dots d(4) would represent a string with four dots: “….” Recall, we can add a character to the end of string s using the + or += operator. For examples += ‘.’ adds a period to the end of s. #include <iostream> #include <string> using namespace std; class Dots { friend ostream& operator<<(ostream & out, const Dots & d) { d.print (out); return out; public: Dots (int n = 0); // constructor: Just call set (n) string get() const; // return s. void set (int n); // set s to n dots or the empty string if n <0. Dots operator++ (int dummy); // postincrement (add one more dot). Dots & operator++(); // preincrement (add one more dot). Dots & operator*= (int k); // multiply # of dots by k, when k >=0. Dots operator* (int k) const; // like *=, but don’t modify *this. void print (ostream & out, bool endline = false) const; // output s and possibly an endl. private: string s; }; Dots::Dots (int n) string Dots::get() const void Dots::set(int n) Dots Dots:: operator++ (int dummy) Dots & Dots::operator++ ( ) Dots & Dots:: operator*=(int k) Dots Dots :: operator* (int k) const void Dots: :print (ostream & out, bool endline) const Show transcribed image text 8. Implement the Dots class shown below that represents a string of zero or more dots (i.e. periods). For example Dots d(4) would represent a string with four dots: “….” Recall, we can add a character to the end of string s using the + or += operator. For examples += ‘.’ adds a period to the end of s. #include #include using namespace std; class Dots { friend ostream& operator
Expert Answer
Answer to 8. Implement the Dots class shown below that represents a string of zero or more dots (i.e. periods). For example Dots d…
OR