Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Queequeg92 committed Nov 17, 2014
1 parent dc494d2 commit 646241c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ch16/ex16.14.15/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Screen {
typedef std::string::size_type pos;
Screen() = default; // needed because Screen has another constructor
// cursor initialized to 0 by its in-class initializer
Screen(char c):contents(ht * wd, c) { }
Screen(char c):contents(H * W, c) { }
char get() const // get the character at the cursor
{ return contents[cursor]; } // implicitly inline
Screen &move(pos r, pos c); // can be made inline later
Expand All @@ -25,4 +25,12 @@ class Screen {
std::string contents;
};

template<unsigned H, unsigned W>
inline Screen<H, W>& Screen<H, W>::move(pos r, pos c)
{
pos row = r * width;
cursor = row + c;
return *this;
}

#endif // SCREEN_H

0 comments on commit 646241c

Please sign in to comment.