惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
The Cloudflare Blog
博客园 - 聂微东
博客园 - 司徒正美
量子位
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
A
About on SuperTechFans

博客园 - 于光远

泛型编程 分区理论知识整理 SPI协议及驱动开发框架 I2C协议及驱动开发框架 使用qemu 加载linux-6.18.1内核 linux 内核 策略模式 单例模式 Linux性能分析:从监控到优化的完整工具链 C++模板元编程实现序列化与反序列化 引用 bootchart linux 脚本打印时间 接口编程 不定参数解析,结合tuple 独立于main运行的程序 类模板继承 Flash HIDL --HelloWorld
std::ostream & operator<<
于光远 · 2022-03-10 · via 博客园 - 于光远
#include <iostream>
#include <iostream>
#include <string>

class test{
public:
    test(const std::string _domain,const std::string _interface,const std::string _instance);
private:

    std::string domain_;
    std::string interface_;
    std::string instance_;
   friend  std::ostream &operator<<(std::ostream &_out, const test &_address);
};

test::test(const std::string _domain,const std::string _interface,const std::string _instance) {
    // TODO: handle error situation (_address is no valid CommonAPI address)
    domain_ = _domain;
    interface_ = _interface;
    instance_ = _instance;
}

std::ostream &
operator<<(std::ostream &_out, const test &_address) {
    _out << _address.domain_
          << ":" << _address.interface_
          << ":" << _address.instance_;
    return _out;
}

int main(){
    test t("a","b","c");
    std::cout<<t<<std::endl;
    return 0;
}
ygy@ygy-VirtualBox:~/work/tmp$ g++ b.cpp 
ygy@ygy-VirtualBox:~/work/tmp$ ./a.out 
a:b:c

posted @ 2022-03-10 14:26  于光远  阅读(675)  评论()    收藏  举报