J
Jeroen
Hi,
Assume a function which returns an object of type 'my_class':
my_class get_class()
{
...
}
Now I have the following question:
void my_function(my_class m)
{
...
}
my_function(get_class());
Question: in this call to my_function, is the copy constructor of
my_class called to make a copy of the object returned by get_class? Or
can a smart compiler skip that step? At first glance I would think that
the copy contructor must be called because a copy of my_class must be
created on the stack when calling my_function...
A similar question is about the following code:
my_class my_function()
{
...
return get_class();
}
Is a copy constructor called to copy the object returned by get_class?
Or can a smart compiler skip that step?
Thanx for any answers,
Jeroen
Assume a function which returns an object of type 'my_class':
my_class get_class()
{
...
}
Now I have the following question:
void my_function(my_class m)
{
...
}
my_function(get_class());
Question: in this call to my_function, is the copy constructor of
my_class called to make a copy of the object returned by get_class? Or
can a smart compiler skip that step? At first glance I would think that
the copy contructor must be called because a copy of my_class must be
created on the stack when calling my_function...
A similar question is about the following code:
my_class my_function()
{
...
return get_class();
}
Is a copy constructor called to copy the object returned by get_class?
Or can a smart compiler skip that step?
Thanx for any answers,
Jeroen