ostream

    -2热度

    4回答

    return (dayCheck = false) ? cout << "On the " << day << "th Day of Christmas, My True Love Gave to Me: " << endl << Christmas(day, count, true) : (count != 0) ? cout << arr[count] << endl

    2热度

    2回答

    我想测试像下面这样一个简单的事情: #include <iostream> #include <boost/variant.hpp> template<typename T1,typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1,T2>& dt){ os << dt.first <<

    -3热度

    1回答

    需求是创建一个流,将其传递给第二个函数进行修改(它必须以这种方式传递,因为输出需要访问私有数据成员单独的课程)。然后输出修改后的流。它按原样编译,但只返回MyStream的地址,我需要它返回流。 /* Prints the details of the media collection. */ void MediaCollection::PrintMediaDetails() const{

    0热度

    3回答

    我有一个动态分配的内存: //dynamic buffer char *mybuffer; cin>>n; mybuffer=new char[n]; //open file for reading ifstream inpt(filename.c_str(), ios::binary); for(unsigned int i=0;i<n;i++){ //copy ever

    1热度

    2回答

    我正在用MPI编写一个C++程序(C接口,没有提升等)。在我的程序中,我有许多输出,可以输出到文件,也可以只输入0级。是否有避免 写入if (rank == 0) cout << string的好方法? 但是也有一些我的电脑我的MPI实现的工作方式有两种,但都有些站不住脚对我说: if (rank != 0) cout.setstate(ios_base::badbit); 这样有效

    -2热度

    1回答

    给定一个载体,诸如: vector<Something*> a; 我想调用函数whoAmI()每Something对象。我想将返回值(string)附加到向量中的所有对象的ostream。 这里是我的代码: std::transform(a.begin(), a.end(), std::ostream_iterator<std::string>(outstream_), std::mem_fn

    0热度

    4回答

    我想要在cout上重定向的每一行的开头都有一个前缀的ostream; 我试试这个: #include <iostream> #include <thread> class parallel_cout : public std::ostream { public: parallel_cout(std::ostream& o):out(o){} template <typename T>

    2热度

    1回答

    我有以下代码: ostream.write(reinterpret_cast<const char*>(&bone.parent_index), sizeof(bone.parent_index)); 现在,这是对的东西,应该是相当简单明了了大量的代码。我想知道是否存在一种使用较少代码在功能上编写相同内容的方法;最好有这样一个接口: ostream.write(bone.parent_inde

    0热度

    1回答

    在C++ primer中第4节8.8.1章节: 为什么没有复制或分配给IO对象? ofstream out1, out2; out1 = out2; // error: cannot assign stream objects ofstream print(ofstream); // error: can't initialize the ofstream parameter out2

    1热度

    2回答

    上一类项目工作到文件,所以必须使用的fstream(用于输入/输出)的unique_ptr,并创建新的文件中写入固定长度的员工记录到(使用员工的EmployeeRec结构) 。 的数据时,我实际上并不被写入以下......至少我没有表现流中它在Visual Studio中寻找和文件从来没有真正建立,我可以找到在任何时候数据该程序的目录。编译好,但我必须错过一些东西。有任何想法吗? 适用代码: 在E