locked
double declaration problem

    Question

  • hello, this is my problem:

    when i write, for example:

    int a;     //50
    a=0;      //51

    (i have italian visual studio, si i try to translate)
    it says:

    \main.cpp(51) : error C4430: type missing
    1>.\main.cpp(51) : error C2086: 'int a': redefinition

    i reinstalled visual studio twice, and same error! :-(

    how can i fix it?
    Saturday, September 01, 2007 3:17 PM

Answers

  • You'll get these errors when you try to write code outside of a function.  For example:

    #include "stdafx.h"

    int a;
    a = 0;  // C4430, C2086
    int abc = 0;  // okay

    int _tmain(int argc, _TCHAR* argv[]) {
      a = 0;  // okay
      return 0;
    }
    Saturday, September 01, 2007 6:55 PM
    Moderator

All replies

  • Hi,

    Seems that you use the same name for two vars.

    Change name to the variable.

    For Example in:

    int A,
    A = 0;


    Ciao Smile

    Saturday, September 01, 2007 5:30 PM
  • it's the same.....
    if i change it to:

    int abc;
    abc=0;

    same error..... :-(
    Saturday, September 01, 2007 5:33 PM
  • You'll get these errors when you try to write code outside of a function.  For example:

    #include "stdafx.h"

    int a;
    a = 0;  // C4430, C2086
    int abc = 0;  // okay

    int _tmain(int argc, _TCHAR* argv[]) {
      a = 0;  // okay
      return 0;
    }
    Saturday, September 01, 2007 6:55 PM
    Moderator
  •  

    thank you!!!

    it's a stupid problem...i study c++ from 2 years and i felt on this error!!!!

    thank u! :-)

    Saturday, September 01, 2007 7:14 PM