-6ren">
gpt4 book ai didi

c++ - "ofstream"作为函数参数

转载 作者:IT老高 更新时间:2023-10-28 12:37:12 34 4
gpt4 key购买 nike

有没有办法像

一样将输出流作为参数传递

void foo (std::ofstream dumFile) {}

我试过了,但它给了

error : class "std::basic_ofstream<char, std::char_traits<char>>" has no suitable copy constructor

最佳答案

当然有。只是使用引用。像这样:

void foo (std::ofstream& dumFile) {}

否则会调用复制构造函数,但没有为类ofstream定义。

关于c++ - "ofstream"作为函数参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9658720/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com