Problem with definition of variable

  • Thread starter Thread starter apprentice159
  • Start date Start date
A

apprentice159

Guest
Hello, I have following problem,
I was writing some app in VS C++ 2010 Express and at once I wanted to define some variable, just like this:

int x;
x = 5;

But I got these errors (both of them pointing to the second line from the code above):

"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2086: int x : redefinition"



It happened in Win32 program and I tried to make a new project (Win32 and also Console), but it behaves in same way.

Here is the whole code (default example with those two lines added):

#include "stdafx.h"

using namespace System;

int x;
x = 5;

int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
return 0;
}



When I wrote it to the one line, like this:

int x = 5;
then there was no problem at all, so I really dont understand it...


There has to be something wrong set in whole enviroment, or I dont know...
I would be glad for someones help, so I wouldnt have to reinstall the whole VS.

Continue reading...
 
Back
Top