ostream Questions
1
Solved
INTRODUCTION
void read_foo (std::ifstream& out);
void write_foo (std::ofstream& out);
I have these two functions where one is supposed to read from a file, and the other is supposed to w...
2
Solved
I can do
std::ostream& out = condition ? std::cout : std::ofstream(filename);
but how do I close in case of out = std::ofstream(filename)?
1
Solved
For a school assignment, I am trying to use a vector of unique pointer's to Employee objects to access the Employee data, but can't figure out the syntax/compiler errors. Can anybody please tell me...
1
Solved
When creating formatted output for a user defined type it is often desirable to define custom formatting flags. For example, it would be nice if a custom string class could optionally add quotes ar...
5
Solved
I think it should be 01 but someone says its "undefined", any reason for that?
5
Solved
Why I can't just create an "empty" stream for my output like this
std::ostream out;
?
This rows is apparently illegal with both clang 3.4 and gcc 4.8.1 under linux with libstdc++, I really don'...
2
Solved
i need to implement a number class that support operator << for output.
i have an error: "identifier "ostream" is undefined" from some reason eventhough i included and try also
here t...
Agglutinate asked 14/5, 2013 at 11:7
2
Solved
Right, I'm not even sure how to correctly formulate this; I feel it's a bit of an involved question. I'm sure someone can help me out here though.
This is what I want to do:
Have a single class ...
Kerikeriann asked 21/4, 2013 at 19:38
1
Solved
class foo {
public:
friend ostream& operator << (ostream &os, const foo &f);
foo(int n) : a(n) {}
private:
vector <int> a;
};
ostream& operator << (ostream &...
Dravidian asked 3/4, 2013 at 13:27
6
I've been trying to find an answer to this, but no one seems to have exactly the same problem as I do.
I am working with several derived classes. The ostream operator << for each of these sh...
Lakendra asked 17/5, 2011 at 6:56
1
Solved
I have read through Should operator<< be implemented as a friend or as a member function? and Overloading Insertion Operator in C++, looks like the similar problem, but didn't fix my own prob...
2
Solved
I decided to try Visual Studio 2012 Express today. First thing to do was to write "Hello world!" application, however, I couldn't make it work. I created a Windows console application project, wrot...
3
Solved
I'm looking into providing ostream operators for some math classes (matrix, vector, etc.) A friend has noted that the gcc standard library implementation of the ostream operator for std::complex in...
4
Solved
I'm working on some homework and receiving the strangest error. Hoping you can help. I am getting this error:
Cannot access private member in class
Note: I am obviously not done writing this b...
Silures asked 7/10, 2012 at 21:2
3
Solved
I'm timing the difference between various ways to print text to standard output. I'm testing cout, printf, and ostringstream using both \n and std::endl. I expected std::endl to make a difference w...
Muskellunge asked 1/10, 2012 at 14:29
2
Solved
By definition taken from: http://www.cplusplus.com/reference/iostream/ostream/flush/ , it is not clear why the function exists, and for what purpose you would use it for. Why not call flush(), ever...
3
Solved
I've got a struct which looks like this:
sturct person
{
string surname;
person(string n) : surname(n) {};
}
I need to overload operator<< for std::ostream and person. I wrote this funct...
4
Solved
What is the difference between ostream and ostringstream? When would you use one versus the other?
Sholom asked 21/8, 2012 at 12:3
1
Solved
I have a problem to overload the << stream operator and I don't find the solution :
template<class T, unsigned int TN>
class NVector
{
inline friend std::ostream& operator<<...
2
Solved
Everything was fine until I moved my objects to a namespace. And now the compiler claims that my Color attributes are private.
I thought the whole point of friends was to share encapsulated inform...
Nisen asked 1/5, 2012 at 22:33
2
Solved
My computer science professor wants us to find the declaration of cout. I've compiled a simple Hello world program using g++ and the -E parameter. Here's what my hello.cpp looks like:
#include <...
Brunhilde asked 11/3, 2012 at 4:14
4
Solved
I'm trying to make a simple logger class, and I want the ability to either log to either a generic ostream (cout/cerr) or a file. The design I have in mind is to allow the constructor to either tak...
2
Solved
We have created and filled some std::vector<uchar> with openCV imencode for example. Now we want to stream it for example into some http_lib which can take some sort of ostream (ostringstream...
5
Solved
I'm defining a class like this:
class StaticRuntimeContext {
public:
enum Verbosity {
kHIGH,
kMEDIUM,
kLOW,
kSILENT
};
static void Construct();
static std::ostream& stdout1() {return ...
2
Solved
Does anybody know if there is a trick to toggle all the cout << functions to not print out visible output? I am trying to hack together some code written by me and some other people to put to...
© 2022 - 2024 — McMap. All rights reserved.