how the language works on the underlying

I'm a beinner and i want to know how the language works on the underlying,
can you explain me what happens exactly when i create and initalize an object
in the following example :
 
int a = 10; // 

if we use the = is copy initalization that means that the value of the right-hand operand is created into the left-hand operand, but what exactly means ? the compiler creates a temporary or what ? or it is a simple copy ?
when a compiler creates a temporary ?
then , i'm studying the c++ primer book and for now ( first 100 pages ) i've studied just one case when we use temporary , do you think i will learn more in the next pages ? thank
No temporary object is required for the simple example you gave.
Specifics vary with the hardware platform, but in general what happens is as follows:
- Load 10 into a register
- Store the contents of the register at address of a.
No temporary object is required for the simple example you gave.

when a temporary is required ?
for example when we print a stream :

 
std::cout << "hello" << "world" << std::endl; 
"
is the same as
 
(std::cout << "hello") << "world " << std::endl; 

here is created a temporary ?
Last edited on
It returns a reference to the ostream so it would be almost the same as

1
2
3
std::cout << "Hello";
std::cout << "world";
std::cout << std::endl;


http://www.cplusplus.com/reference/ostream/ostream/operator%3C%3C/
Topic archived. No new replies allowed.