Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

练习19.14答案有误 #78

Open
Butter934 opened this issue Mar 13, 2021 · 0 comments
Open

练习19.14答案有误 #78

Butter934 opened this issue Mar 13, 2021 · 0 comments

Comments

@Butter934
Copy link

练习19.14

class Screen {
public:
	typedef std::string::size_type pos;
	char get_cursor() const { return contents[cursor]; }
	char get() const;
	char get(pos ht, pos wd) const;
private:
	std::string contents;
	pos cursor;
	pos height, width;
};

get_curcor返回类型为char
故以下代码

auto pmf = &Screen::get_cursor;
pmf = &Screen::get;

合法,含义为:
第一步,推导出pmf的类型(auto)为char (Screen::*)() const ,并将指向get_cursor成员函数的指针赋给pmf
第二步,将指向成员函数char get()const的指针赋值给pmf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant