⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main3.cpp

📁 C++Primer中文版 第三版 深入系列 Primer 第三版 著 中中文文版版潘爱民张丽译 Addison-Wesley 中国电力出版社 www.infopower.com.cn S
💻 CPP
字号:
// Section 13.3
// $ CC screen.cpp main3.cpp

/*
  Screen Object ( 3, 3 )

  abc
  def
  ghi
*/

#include <iostream>
using std::cout;

#include <string>
using std::string;

#include "screen.h"

int main() {
        Screen sobj(3,3); // constructor defined in Section 13.3.4
        string init("abcdefghi");

        cout << "Screen Object ( "
             << sobj.height() << ", "
             << sobj.width() << " )\n\n";

        // Set the content of the screen
        string::size_type initpos = 0;
        for ( int ix = 1; ix <= sobj.width(); ++ix )
                for ( int iy = 1; iy <= sobj.height(); ++iy )
                {
                        sobj.move( ix, iy );
                        sobj.set( init[ initpos++ ] );
                }

        // Print the content of the screen
        for ( int ix = 1; ix <= sobj.width(); ++ix )
        {
                for ( int iy = 1; iy <= sobj.height(); ++iy )
                        cout << sobj.get( ix, iy );
                cout << "\n";
        }

        return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -