Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporary Object confusion

Tags:

c++

temporary

Have a look at this code snippet

struct S{ int i; int j;};

int main()
{
   assert(S().i ==  S().j) // is it guaranteed ?
}

Why?

like image 349
Bollinger Avatar asked Dec 07 '10 16:12

Bollinger


People also ask

What can cause temporary mental confusion?

Common causes of sudden confusiona lack of oxygen in the blood (hypoxia) – the cause could be anything from a severe asthma attack to a problem with the lungs or heart. an infection anywhere in the body, especially in elderly people. a stroke or TIA ('mini stroke') a low blood sugar level (hypoglycaemia)

What is temporary confusion?

Sudden confusion, sometimes called delirium or encephalopathy, can be a sign of many health problems. It comes on quickly, within hours or days. It's different from dementia (like Alzheimer's disease), which causes slow changes over months or years.

Can stress cause temporary confusion?

Visit our “Stress Response” article for all of the ways stress responses prepare the body. This sudden change can cause temporary confusion as the body and brain adjust to the emergency readiness.

Is sudden confusion a symptom of stroke?

What are the signs of stroke in men and women? Sudden numbness or weakness in the face, arm, or leg, especially on one side of the body. Sudden confusion, trouble speaking, or difficulty understanding speech. Sudden trouble seeing in one or both eyes.


1 Answers

is it guaranteed ?

Yes it is guaranteed. The values of S().i and S().j would be 0. () implies value initialization. (that means i and j would be zero-initialized because S is a class without a user defined default constructor)

like image 178
Prasoon Saurav Avatar answered Sep 30 '22 17:09

Prasoon Saurav