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

是否可以放开所有的私有函数? #11

Closed
wtdcode opened this issue Nov 18, 2019 · 3 comments
Closed

是否可以放开所有的私有函数? #11

wtdcode opened this issue Nov 18, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@wtdcode
Copy link
Member

wtdcode commented Nov 18, 2019

相关 issue #2 #7 以及论坛和邮件的一些讨论。

之前不放开私有函数的考虑主要是不希望大家修改 .h,也就是类的签名,但是实际上我们在评测的时候也是从头编译,因此只要学生保证可以在标准环境编译并且类公开接口不变的话应该不会影响评测,但是具体的情况需要尽快的评估。

另外一个根本的解决方法是写成 pimpl,学生自由实现 impl 类,比如

// Analyser.h
class Analyser{
// ...
public:
    void DoSth() {this->impl_->DoSth();}
// ...
private:
// ...
    std::unique_ptr<AnalyserImpl> impl_;
// ...
}

// AnalyserImpl.h
class AnalyserImpl{
public:
    void DoSth();
// and any other functions or members.
}
@wtdcode wtdcode added the enhancement New feature or request label Nov 18, 2019
@wtdcode
Copy link
Member Author

wtdcode commented Nov 18, 2019

有没有个C++带手子论证下。

@wtdcode
Copy link
Member Author

wtdcode commented Nov 21, 2019

不能 明年加油。

@wtdcode wtdcode closed this as completed Nov 21, 2019
@wtdcode
Copy link
Member Author

wtdcode commented Nov 23, 2019

是不是可以放开添加的权限?因为公有函数实现依赖私有函数,放开已有的私有函数修改权限势必意味着需要放开公有函数的修改权限,但是一个弥补的方案是放开添加任意私有函数的权限。

@wtdcode wtdcode reopened this Nov 23, 2019
wtdcode added a commit to BUAA-SE-Compiling/miniplc0-handbook that referenced this issue Nov 23, 2019
@wtdcode wtdcode closed this as completed Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant