What do you mean by a temporary instance of a class?
Answers
Answered by
19
Temporary instances are constructors that live in the memory for as long as it is being used in the expression, in which they have been invoked.eg:-
class test
{
int m;
public:
test(int a)
{
m=a;
}
void print ();
{
cout<<m;
}
};
void main()
{
test t(2);//is an object
test(2).print();//is a temporary instance
}
Answered by
1
Answer:
you may wish to use an instance temporarily to invoke a method or chain of methods. Temporary instances are instances that are instantiated in order to invoke a method or chain of methods, then are immediately discarded.
Explanation:
MARK AS BRAINLINIST
Similar questions