ostream Questions

1

Solved

cout is an instance of type "ostream" ostream::operator<< says that If the operation sets an internal state flag that was registered with member exceptions, the function throws an exception...
Radioactivate asked 22/6, 2018 at 1:20

3

Solved

I mean, I was trying to overload the operator<< inside the class like this class A { public: ostream &operator<<(ostream &os);// which doesnt work private: friend ostrea...
Purusha asked 19/2, 2012 at 17:2

2

Solved

I'm working with a basic std::ofstream object, created as follows: output_stream = std::ofstream(output_file.c_str()); This creates a file, where some information is put in. Let me show an examp...
Hb asked 21/3, 2018 at 11:22

2

Solved

I am working on a project that uses libzip. I'm working in c++14 and I wrote a tiny wrapper around libzip to make my life easier. I have an std::ostream object built around custom class that inher...
Outflow asked 26/12, 2017 at 17:45

1

Solved

I'm taking a quiz on an intro level class in C++ and I'm trying to understand a question. After searching the internet and not getting an answer, so here I am. Which of the following function decl...
Maestro asked 11/10, 2017 at 14:3

4

Solved

So I'm trying to read input like this from the standard input (using cin): Adam English 85 Charlie Math 76 Erica History 82 Richard Science 90 My goal is to eventually store each data piece...
Fraudulent asked 13/3, 2016 at 18:58

1

According to the C++ standard (§30.7.5.2.4 of C++17 draft (N4659)), out << ch will not perform a widening operation on ch, if ch is a char and out is a std::ostream. Does this imply that std...
Elective asked 6/6, 2017 at 1:38

1

Solved

I want to use std::ostream like this: int main() { std::ostream os; os << "something ..." << std::endl; return 0; } There's an error said that the ostream constructor is protected...
Missi asked 18/7, 2017 at 16:6

1

Solved

It seems to me, that there is an inconsistency in the C++ standard, specifically in §30.7.5.2.4 of the C++17 draft (N4659), about when characters are widened in formatted output operations on outpu...
Downer asked 5/6, 2017 at 20:41

2

Solved

When I ran the following program #include <iostream> int main() { char c = 'a'; std::cout << c << std::endl; std::cout.operator<<(c) << std::endl; return 0; } ...
Glenglencoe asked 7/7, 2015 at 16:54

2

#include <iostream> #include <sstream> #include <thread> using namespace std; int main() { auto runner = []() { ostringstream oss; for (int i=0; i<100000; ++i) oss <&l...
Pentad asked 31/1, 2017 at 17:41

1

Solved

For the fun and experience of it, I'm modifying and exploring the source code for Blobby Volley 2 1.0 (Linux). Well... I would be modifying the source code, but I can't even get the program to com...
Freehanded asked 30/8, 2016 at 2:42

6

Solved

I want to write a simple program that depending on the options passed it the executable will print the output to the screen or to a file. The program is simple. #include<iostream> int main(i...
Phonemics asked 19/7, 2016 at 9:46

6

Solved

I am toying around with streams for a bit and can't get my head around the following. Here we have a basic ostream ptr that is set to different output streams, whether it is cout, cerr or a file....
Spiral asked 4/5, 2016 at 19:54

3

Solved

What is the most elegant way, in your opinion, to print to std::cout using std::ostream_iterator in C++11 and avoid printing a trailing delimeter? The object I'm printing has bidirectional iterat...
Heptagonal asked 17/6, 2012 at 18:50

2

Solved

I'm working on a homework project for a virtual rolodex that has called for a main class, a rolodex class, and a card class. To output the contents of all of the "cards" to the console, the assignm...
Evered asked 1/4, 2011 at 0:20

2

Solved

I have a class template that will output a list of objects stored in the array. I am getting the following error and I am confused where the error is caused since the error is in the .obj and...
Steam asked 22/11, 2015 at 22:42

1

It is a well known method to copy a stream into another using rdbuf: #include <iostream> #include <fstream> int main() { std::ifstream in{"/tmp/foo.txt"}; std::cerr << in.rdbu...
Entablature asked 20/11, 2015 at 14:42

4

Solved

I would like to send data from within my C++ program to an external pipeline, like so: FILE* file = popen("my_prog -opt | other_prog", "w"); std::ostream fileStream = some_function(file); fileStre...
Clyte asked 14/11, 2015 at 22:36

2

I have a polynomial class, and its natural representation is its coefficients. If a coefficient is set, then its a 1 for binomial basis, 1 or 2 for trinomial basis, etc. For example, in a binomial ...
Needleful asked 11/11, 2015 at 21:32

3

Solved

I have the following code: #include <iostream> #include <vector> namespace X { std::ostream& operator<<(std::ostream& os,const std::vector<double>& v){ for (i...
Ropable asked 6/5, 2015 at 15:0

2

Solved

Today I made a small typo in my program, and was wandering why I wasn't getting any output, although the program compiled fine. Basically it reduces to this: #include <iostream> int main() ...
Thought asked 18/4, 2015 at 22:6

3

Solved

Why can one cast a std::ostream to a void pointer? I am not aware of any such conversion operator in std::ostream. Code below #include <iostream> int main() { void *p = std::cout; // why d...
Gisellegish asked 21/1, 2015 at 5:31

2

Solved

I have always used cout to print the statement but now I want learn printing by passing the stream, something like void print(std::ostream&) const; my current print function looks like templat...
Philender asked 4/1, 2015 at 20:32

1

Solved

I have a basic question about the arithmetic inserters; § 27.7.3.6.2/1 [ostream.inserters.arithmetic]: When val is of type bool, long, unsigned long, long long, unsigned long long, double, long ...
Batruk asked 6/10, 2014 at 5:20

© 2022 - 2024 — McMap. All rights reserved.