Some C++ questions

Ross Alexander r.alexander@auckland.ac.nz
Mon Oct 27 17:36:00 GMT 1997


Here are a couple of C++ scoping questions I have.

1)

int main()
{
  if (int i = 10)
    i++; // should be okay
  i++; // shold be out of scope
}

SGI CC v7.0 doesn't like the declaration within the if statement.

2)
int main()
{
  for (int i = 0; i < 10; i++)
    cout << i;

  for (int i = 0; i < 10; i++) // should be fine
    cout << i;
}

Both SGI CC v7.0 and SunPro CC 4.2 barf horribly at this.

Who is right?


Many thanks

-- 
Ross Alexander                       r.alexander@auckland.ac.nz
Department of Statistics
University of Auckland
New Zealand



More information about the Gcc mailing list