#include<iostream>
#include<vector>
using namespace std;
class Screen;
class Window_mgr{
public:
using ScreenIndex = std::vector<Screen>::size_type;
void clear(ScreenIndex i);
void show(){
cout<<"size="<<screens.size()<<endl;
for(int i=0;i<screens.size();i++){
cout<<screens[i].height<<" ";
cout<<screens[i].width<<" ";
cout<<screens[i].contents<<endl;
}
}
private:
std::vector<Screen> screens{Screen(24,80,'*')};
};
class Screen{
public:
friend class Window_mgr::clear();
typedef std::string::size_type pos;
Screen()=default;
Screen(pos ht,pos wd,char c):height(ht),width(wd),contents(ht*wd,c);
Screen & set(char);
Screen & set(pos r,pos col,char ch)
{
contents[r*width+col] = ch;
return *this;
}
private:
pos cursor = 0;
pos height = 0,width = 0;
std::string contents;
};
Window_mgr::clear(ScreenIndex i){
Screen &s = screens[i];
s.contents = string(s.height*s.width,' ');
}
int main()
{
Window_mgr wm;
wm.show();
// wm.clear(1);
wm.show();
}
BUG
最新推荐文章于 2024-06-07 13:55:54 发布