-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathex7_24.h
More file actions
33 lines (26 loc) · 680 Bytes
/
ex7_24.h
File metadata and controls
33 lines (26 loc) · 680 Bytes
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
//
// ex7_24.cpp
// Exercise 7.24
//
// Created by pezy on 11/14/14.
// Copyright (c) 2014 pezy. All rights reserved.
//
#ifndef CP5_ex7_24_h
#define CP5_ex7_24_h
#include <string>
class Screen {
public:
using pos = std::string::size_type;
Screen() = default; // 1
Screen(pos ht, pos wd) : height(ht), width(wd), contents(ht * wd, ' ') {} // 2
Screen(pos ht, pos wd, char c) : height(ht), width(wd), contents(ht * wd, c)
{
} // 3
char get() const { return contents[cursor]; }
char get(pos r, pos c) const { return contents[r * width + c]; }
private:
pos cursor = 0;
pos height = 0, width = 0;
std::string contents;
};
#endif