Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Problem with definition of variable

$
0
0

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 don't understand it...

There has to be something wrong set in whole enviroment, or I don't know...
I would be glad for someone's help, so I wouldn't have to reinstall the whole VS.


Viewing all articles
Browse latest Browse all 15302

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>