猫史档案馆


【求助】C++运算符重载?

用户:1111111111111111211111111111111112查看:1 回复:2 评论:1 创建时间:2023-07-18T10:54:47


刚学c++看到cout << "hello,world";向输出流输入hello,world 因为深受Python影响,似乎真的很奇怪我只是想知道对象如何在屏幕上输出一些东西或者在不调用任何方法的情况下执行语句和函数之类的事情,后面才知道使用<<似乎调用了cout operator<<方法,那么cout<<"hello,world";是否可以写成

#include <iostream>
using namespace std;

int main() {
    cout.operator<<("hello,world");
    return 0;
}
//但是输出了一串数字,类似内存地址的东西0x402004
//why?不应该输出hello,world吗?

 

 

 


回复

上一页1 页 / 共 1下一页
1111111111111111211111111111111112

dddd

点赞0


评论


无人在意的传说无人在意的传说

我来

#include<bits/stdc++.h>
using namespace std;
int main(){
    cout<<"Hello,word";
    return 0;
}

点赞0


评论