variable declaration

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rahul

    variable declaration

    Hi Everyone,

    I had the following declaration and i expected the compiler to give
    an error, but it didn't, how does it interpret the declaration?

    const * int ptr;

    Thanks in advance!!!
  • Juha Nieminen

    #2
    Re: variable declaration

    Victor Bazarov wrote:
    The '*' symbol cannot be followed by 'int'.
    result = a * int (b);

    ;)

    Comment

    • Jeff Schwab

      #3
      Re: variable declaration

      Juha Nieminen wrote:
      Victor Bazarov wrote:
      >The '*' symbol cannot be followed by 'int'.
      >
      result = a * int (b);
      What compiler does that? GCC 4.2 rejects both of these:

      int main() { const * int ptr; }
      int main() { void* ptr = 0; const * int ptr; }

      Both cases cause the same diagnostic:

      g++ -ansi -pedantic -Wall main.cc -o main
      main.cc: In function 'int main()':
      main.cc:1: error: expected unqualified-id before 'int'
      main.cc:1: error: expected initializer before 'int'

      Comment

      • Victor Bazarov

        #4
        Re: variable declaration

        Juha Nieminen wrote:
        Victor Bazarov wrote:
        >The '*' symbol cannot be followed by 'int'.
        >
        result = a * int (b);
        >
        ;)
        I meant in a declaration. See subj.

        V
        --
        Please remove capital 'A's when replying by e-mail
        I do not respond to top-posted replies, please don't ask


        Comment

        Working...