Hello,
I have a doubt about this operator, and I haven't found the answer in
internet (yet).
When calling the operator << several times in an expression, are all
parameters evaluated first and then passed to cout::<<, or are being
passed when they are evaluated ?
An example to clarify my question :
int foo()
{
cout << "calling foo";
return 1;
}
......
cout << "i = " << foo() << endl;
Should I see this:
calling fooi = 1
or
i = calling foo1 ??
Or is it undefined behaviour?
So going to the original question.... is "i=" passed to cout::<< first
and then foo() is evaluated and passed to cout::<<, or is foo()
evaluated and just then "i = " and foo() are passed to cout::<< ?? Or
undefined behaviour?
Thanks in advance,
Luis 1 1432
Victor, Jack, I really appreciate your answers, now it is also clear
to me.
Thanks a lot,
Luis This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sprite |
last post by:
I write the following code
int x1 = 5;
std::cout<<x1--<<" "<<x1--<<" "<<x1;
and got the result
4 5 3
in VS2003
who can explain that, THX
|
by: bluekite2000 |
last post by:
Here A is an instantiation of class Matrix. This means whenever user
writes
Matrix<float> A=rand<float>(3,2);//create a float matrix of size 3x2
//and fills it up w/ random value
cout<<A;
the following will be printed
A
3
2
|
by: Filipe Sousa |
last post by:
Hi!
Could someone explain to me why this operation is not what I was expecting?
int main()
{
int x = 2;
std::cout << x << " " << x++ << std::endl;
return 0;
}
|
by: subramanian100in |
last post by:
Consider the code:
#include <iostream>
using namespace std;
int main( )
{
cout << "test string ";
cout.operator<<(10).operator<<(endl);
|
by: suresh |
last post by:
Hi,
For this code snippet, I get the following output, which I am unable
to understand.
(2^31 = 2147483648)
cout<< -2147483648 << endl;
cout << numeric_limits<int>::min() <<',' <<
numeric_limits<int>::max()<< endl;
| |
by: Alex Vinokur |
last post by:
void foo (int n)
{
std::ostringstream oss;
oss << "ABCD: " << n << std::endl;
std::cout << oss.str() << std::flush;
}
That function has been invoked in multiprocessing mode.
|
by: barcaroller |
last post by:
In the boost::program_options tutorial, the author included the following
code:
cout << "Input files are: "
<< vm.as< vector<string()
<< "\n";
Basically, he is trying to print a vector of string, in one line. I could
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |