cout Questions

3

Solved

I am trying to overload << operator. For instance cout << a << " " << b << " "; // I am not allowed to change this line is given I have to print it in form...
Marquettamarquette asked 3/10, 2018 at 5:17

3

Solved

I'm practicing using mulitple files and header files etc. So I have this project which takes two numbers and then adds them. Pretty simple. Here are my files: main.cpp #include <iostream> ...
Quip asked 7/7, 2012 at 14:43

1

Solved

For the following struct struct TestClass { TestClass() : mat(Eigen::Matrix3i::Zero()) {} Eigen::Matrix3i mat; }; I would like to have an overloaded operator<< to print the mat member to...
Noletta asked 20/9, 2018 at 9:10

2

Solved

I am trying to do something as simple as: std::cout << e << std::endl; where e is of type Eigen::Affine3d. However, I am getting unhelpful error messages like: cannot bind 'std::o...
Hyksos asked 10/9, 2018 at 10:28

7

Solved

I'm working on a program that makes heavy use of "cout << strSomething;" to log information to the console. I need to modify the program so that all console output goes to both the console AN...
Pridgen asked 9/5, 2011 at 20:39

6

Solved

I'm pretty new to C++, and I'm using std::cout for debugging purposes. Though, I'd really like to be able to just use cout rather than the whole std::cout thing. I know i could import the std name...
Fredric asked 7/8, 2018 at 8:50

3

I have a C++ learning demo here: char c = 'M'; short s = 10; long l = 1002; char * cptr = &c; short * sptr = &s; long * lptr = &l; cout << "cptr:\t" << static_cast<void...
Hoffmann asked 27/7, 2018 at 3:1

3

Solved

the following code: myQueue.enqueue('a'); myQueue.enqueue('b'); cout << myQueue.dequeue() << myQueue.dequeue(); prints "ba" to the console while: myQueue.enqueue('a'); myQueue.enqu...
Quesada asked 24/1, 2010 at 22:44

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

4

Can i design my logging-function in a way, that it accepts concatenated strings of the following form using C++? int i = 1; customLoggFunction("My Integer i = " << i << "."); . cust...
Shirleyshirlie asked 9/6, 2018 at 17:33

2

Solved

Say for example I have a long statement like cout << findCurrent() << "," << findLowest() << "," << findHighest() << "," << findThird()<<"\n"; woul...
Bibliographer asked 16/5, 2018 at 1:40

7

Solved

I tried researching the difference between cout, cerr and clog on the internet but couldn't find a perfect answer. I still am not clear on when to use which. Can anyone explain to me, through simpl...
Hundredth asked 27/5, 2013 at 12:4

7

Solved

I'm trying to print characters in the console at specified coordinates. Up to now I have been using the very ugly printf("\033[%d;%dH%s\n", 2, 2, "str"); But I just had to ask whether C++ had any o...
Wales asked 3/11, 2009 at 23:46

2

Solved

cout is a buffered stream. This means that the data will be written to the buffer and will be printed when the stream is flushed, program terminated or when the buffer is completely filled. I made...
Lecher asked 18/12, 2017 at 17:11

2

Solved

In this statement for (i = 1; i <= n; i++) { cout << i << " \n"[ i == n ]; } what is the last term in cout statement [i==n] doing? This loop prints space separate numbers I gues...
Monofilament asked 14/12, 2017 at 3:41

7

I get this ERROR: "error: overloaded function with no contextual type information". cout << (i % 5 == 0) ? endl : ""; Is what I am doing possible; am I just doing it wrong, or do I have to...
Dorena asked 20/4, 2011 at 6:38

2

Solved

Suppose I have this code: #include <iostream> struct Mine { int a; int b; }; int main() { int Mine::* memberPointerA = &Mine::a; int Mine::* memberPointerB = &Mine::b; st...
Banna asked 27/7, 2017 at 23:28

1

Solved

To my surprise the following code prints 1. std::cout << [](const char* arg){ return arg[0]=='s'; } << std::endl; Can someone explain this, please?
Cavorelievo asked 10/7, 2017 at 2:31

2

According to the top answer to this question, cout << expr is equivalent to cout.operator<<(expr). According to responses to this question, the statement above is untrue. According to...
Sillsby asked 7/6, 2017 at 14:1

1

Here I define a Date, and specify a user-defined conversion. class Date { private: int day; int month; string dateStr; public: Date(int _day, int _month) : day(_day), month(_month) {} operat...

2

I'm trying to insert a unicode value, in this case, \u250F, or ┏, to the console output. I have searched around, and people recommending a variety of things. Before we discuss on what I tried, I am...
Ligature asked 10/11, 2014 at 0:19

4

I need to print some Unicode characters on the Linux terminal using iostream. Strange things happen though. When I write: cout << "\u2780"; I get: ➀, which is almost exactly what I...
Dissimilate asked 5/6, 2013 at 16:7

2

Solved

printf(...) returns the number of characters output to the console, which I find very helpful in designing certain programs. So, I was wondering if there is a similar feature in C++, since the cout...
Astrea asked 29/12, 2016 at 9:45

1

Solved

How do you print the string representation of a std::regex? Say I have a collection of patterns, and I'd like to print the first one that matches: std::vector<std::regex>> patterns = G...
Firestone asked 13/11, 2016 at 4:18

2

Solved

The following code outputs 1, but I expect it to output the address of the function add. What is going wrong? #include <iostream> int add(int x, int y) { return x + y; } int main() { int (...
Seiden asked 8/11, 2016 at 12:29

© 2022 - 2024 — McMap. All rights reserved.