C++助教篇4_Week2找bug
发布日期:2021-05-08 04:54:05 浏览次数:17 分类:精选文章

本文共 401 字,大约阅读时间需要 1 分钟。

为什么下面关于<<的重载会引发error呢?

class MyClass {   public:    MyClass() = default;    friend ostream& operator<<(ostream& out, MyClass& obj);};int main(int argc, const char** argv) {       MyClass a, b;    std::cout << a + b << std::endl;  // error    MyClass c;    c = a + b;    std::cout << c << std::endl;    system("pause");    return 0;}

C++不支持连续比较,但下面确实会输出True

if (2 < 9 < 3) {   	cout << "True" << endl;}
上一篇:内存释放free函数如何知道内存大小
下一篇:pre-binary 安装docker

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2025年04月17日 15时25分23秒