| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 8172 人关注过本帖
标题:未定义的标识符,明明定义了啊。。
取消只看楼主 加入收藏
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
结帖率:76.92%
收藏
已结贴  问题点数:30 回复次数:1 
未定义的标识符,明明定义了啊。。

头文件
*****************************************************************8
#ifndef TOUTOU_H
#define TOUTOU_H

#include<iostream>
#include<string>
using namespace std;
using std::iostream;
using std::string;
using std::cout;
class Screen {
public:
    using pos = std::string::size_type;

    Screen() = default;
    Screen(pos ht, pos wd) :height(ht), width(wd), conents(ht*wd, ' ') {}
    Screen(pos ht, pos wd, char c) :height(ht), width(wd), conents(ht*wd, c) {}

    char get() const { return conents[cursor]; }                                         ***********   cursor未定义
    char get(pos r, pos s)  const { return conents[r*width + s]; }
    Screen &move(pos r, pos s);
    Screen &set(char c);
    Screen &set(pos r, pos s, char c);

    const Screen &display(std::ostream &os) const { do_display(os); return *this; }
    Screen &display(std::ostream &os) { do_display(os); return *this; }

private:
    void do_display const (ostream &os) {
        os << conents;
    }
private:
    pos cursor = 0;
    pos height = 0;
    std::string conents;
    pos width = 0;
};
inline Screen& Screen::move(pos r, pos s) {
    cursor = r*width + s;
    return *this;
}

inline Screen& Screen::set(char c) {
    conents[cursor] = c;
    return *this;
}

inline Screen& Screen::set(pos r, pos s, char c) {
    conents[r*width + s] = c;
    return *this;
}
#endif
 
程序
**********************************************************************
#include"C:\Users\Jin\Desktop\toutou.h"
int main()
{
   

   
    Screen myScreen(5,5,'X');                            ******************* Screen未定义
    myScreen.move(4, 0).set('#').display(cout);          ******************* cout未定义
     cout << "\n";
    myScreen.display(cout);
    cout << "\n";

    return 0;
}
搜索更多相关主题的帖子: default include public 
2016-05-16 22:32
哒哒哒啦啦啦
Rank: 1
等 级:新手上路
帖 子:75
专家分:4
注 册:2016-2-26
收藏
得分:0 
回复 2楼 rjsp
是一个题在github上的答案,不知原来的代码为啥不对呢
2016-05-17 20:36
快速回复:未定义的标识符,明明定义了啊。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046531 second(s), 11 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved