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

StrBlob.h 头文件报错 #73

Open
kagtag opened this issue Jul 31, 2017 · 1 comment
Open

StrBlob.h 头文件报错 #73

kagtag opened this issue Jul 31, 2017 · 1 comment

Comments

@kagtag
Copy link

kagtag commented Jul 31, 2017

参考文件为 https://github.com/Mooophy/Cpp-Primer/blob/master/ch15/ex15.34.35.36.38/StrBlob.h
运行系统为windows 7 professional
IDE为 Visual Studio 2015 professional

出现了两个错误

  1. StrBlob类的两个成员函数 StrBlobPtr bebin()和 StrBlobPtr end()在类外定义处报错
    Declaration is incompatible with StrBlobPtr StrBlob::begin()
    Declaration is incompatible with StrBlobPtr StrBlob::end()

  2. StrBlobPtr类中构造函数无法访问StrBlob类私有成员data
    StrBlobPtr(const StrBlob &a, const size_t sz=0):wptr(a.data),curr(sz){}
    报错信息为
    member StrBlob::data declared at .... is inaccessible.

@ender233
Copy link

@kagtag

使用类型的时候需要知道其定义(类结构),只有使用类指针的时候前置声明就够用了(class Type)
辅助理解: https://stackoverflow.com/questions/16440661/declaration-is-incompatible-with-type

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

2 participants