C++primer 中的Screen类的问题
#ifndef SCREEN_H
#define SCREEN_H
#include<iostream>
using namespace std;
class Screen
{
typedef string::size_type pos;
public:
Screen();
Screen(pos ht,pos wd):height(ht),width(wd),contents(ht*wd,' '){}
Screen(pos ht,pos wd,char c):height(ht),width(wd),contents(ht*wd,c){}
Screen &set(char);
Screen &set(pos,pos,char);
char get()const{return contents[cursor];}//隐式内联,读取光标处的字符
inline char get(pos ht,pos wd)const;//显式内联
Screen &move(pos r,pos c);//能在之后设置成内联
private:
pos cursor;//光标
pos height,width;
string contents;//内容
};
inline Screen &Screen::move(pos r, pos c)
{
pos row=r*width;//计算行的位置
cursor=row+c;//将行内光标移动到指定的列
return *this;//以左值的形式返回对象
}
inline Screen &Screen::set(char c)
{
contents[cursor]=c;
return *this;
}
#endif // SCREEN_H
在main函数调用 Screen sc;
sc.move(4,0).set('#');
报错 E:\Qt\QtProjects\untitled3\main.cpp:9: error: undefined reference to `Screen::move(unsigned int, unsigned int)'
E:\Qt\QtProjects\untitled3\main.cpp:9: error: undefined reference to `Screen::set(char)'
:-1: error: collect2: ld returned 1 exit status
把move set函数之前的Inline 去掉可以通过编译 怎么回事呢