When are temporary variables formed by c++ compiler?, C/C++ Programming

A: Provided that function parameter is "const reference", compiler create temporary variable in following two ways.

a) The actual argument is the correct type, however it isn't Lvalue

double Cube(const double & num)

{

num = num * num * num;

return num;

}

double temp = 2.0;

double value = cube(3.0 + temp); // argument is a expression and not a Lvalue;

b) The actual argument is of the wrong type, however of a type which can be converted to the correct type

long temp = 3L;

double value = cuberoot ( temp); // long to double conversion

 

Posted Date: 3/21/2013 7:28:18 AM | Location : United States







Related Discussions:- When are temporary variables formed by c++ compiler?, Assignment Help, Ask Question on When are temporary variables formed by c++ compiler?, Get Answer, Expert's Help, When are temporary variables formed by c++ compiler? Discussions

Write discussion on When are temporary variables formed by c++ compiler?
Your posts are moderated
Related Questions

construct a console programme for a bank ATM machine.

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

#question. write a program number to alphabet in c++..

write a program that counts the number of occurances of the string in the n-th padovan string p(n)

write a program that counts the number of occurrences of the string in the n-th padovan string p(n)   program 1 : package test.padovanstring; public class PadovanString {

overloadstream insertion opertator to display the data of object on the console


Both malloc & new functions are utilized for dynamic memory allocations & the basic difference is: malloc need a special "typecasting" while it allocates memory for eg. if the poin

C program to count the words: void CountWords();          void main()          {             printf("\n\tcount the words and enter string\n\n\n");             Count