Is it a question?!

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

    Is it a question?!

    I don't decide it, and I need help.

    Q:
    const int* pInt = new int(0);
    delete pInt;
  • tom_usenet

    #2
    Re: Is it a question?!

    On 6 Nov 2003 03:14:10 -0800, xhuazeng@sina.c om.cn (xhzeng) wrote:
    [color=blue]
    >I don't decide it, and I need help.
    >
    >Q:
    >const int* pInt = new int(0);
    >delete pInt;[/color]
    A:
    c:\Dev\test\dot nettest\dotnett est\dotnettest. cpp(2) : error C2059:
    syntax error : 'delete'

    Tom

    Comment

    • Rolf Magnus

      #3
      Re: Is it a question?!

      xhzeng wrote:
      [color=blue]
      > I don't decide it, and I need help.[/color]

      You don't decide what?
      [color=blue]
      > Q:
      > const int* pInt = new int(0);
      > delete pInt;[/color]

      This is a piece of code. Not a valid C++ program, but might be valid as
      part of one.
      But what is the question?

      Comment

      • Michael Kochetkov

        #4
        Re: Is it a question?!


        "xhzeng" <xhuazeng@sina. com.cn> wrote in message
        news:c2d2305d.0 311060314.e3f15 5d@posting.goog le.com...[color=blue]
        > I don't decide it, and I need help.
        >
        > Q:
        > const int* pInt = new int(0);
        > delete pInt;[/color]
        No, it is not. It is not a question. Even
        const int* const i = new int(0);
        delete i;
        is not a question because destructors are allowed to run for const objects
        too.

        --
        Michael Kochetkov.


        Comment

        • Andrey Tarasevich

          #5
          Re: Is it a question?!

          xhzeng wrote:
          [color=blue]
          > I don't decide it, and I need help.
          >
          > Q:
          > const int* pInt = new int(0);
          > delete pInt;[/color]

          It is just a fragment of valid C++ code. Now, what is the question and
          what is it that you "don't decide"?

          --
          Best regards,
          Andrey Tarasevich

          Comment

          • Unforgiven

            #6
            Re: Is it a question?!

            xhzeng wrote:[color=blue]
            > I don't decide it, and I need help.
            >
            > Q:
            > const int* pInt = new int(0);
            > delete pInt;[/color]

            You ran this trough an Internet translator, something like Altavista
            Babelfish, I suspect? Unfortunately, none of us can really make out what the
            question you have is. Perhaps you would be better of finding help on a forum
            where they speak your language.

            --
            Unforgiven

            "You can't rightfully be a scientist if you mind people thinking
            you're a fool."


            Comment

            • Erik

              #7
              Re: Is it a question?!

              If this is an answer =)


              Comment

              • Calum

                #8
                Re: Is it a question?!

                xhzeng wrote:[color=blue]
                > I don't decide it, and I need help.
                >
                > Q:
                > const int* pInt = new int(0);
                > delete pInt;[/color]

                Drop the "const". You can't delete a const pointer.

                Comment

                • Karl Heinz Buchegger

                  #9
                  Re: Is it a question?!



                  Calum wrote:[color=blue]
                  >
                  > xhzeng wrote:[color=green]
                  > > I don't decide it, and I need help.
                  > >
                  > > Q:
                  > > const int* pInt = new int(0);
                  > > delete pInt;[/color]
                  >
                  > Drop the "const". You can't delete a const pointer.[/color]

                  Says who?

                  --
                  Karl Heinz Buchegger
                  kbuchegg@gascad .at

                  Comment

                  • Rolf Magnus

                    #10
                    Re: Is it a question?!

                    Karl Heinz Buchegger wrote:
                    [color=blue]
                    > Calum wrote:[color=green]
                    >>
                    >> xhzeng wrote:[color=darkred]
                    >> > I don't decide it, and I need help.
                    >> >
                    >> > Q:
                    >> > const int* pInt = new int(0);
                    >> > delete pInt;[/color]
                    >>
                    >> Drop the "const". You can't delete a const pointer.[/color]
                    >
                    > Says who?[/color]

                    Says "Calum" :-)

                    And just to make that posting at least a bit useful: pInt is not a const
                    pointer, but a pointer to const.

                    Comment

                    • Peter van Merkerk

                      #11
                      Re: Is it a question?!

                      > > > I don't decide it, and I need help.[color=blue][color=green][color=darkred]
                      > > >
                      > > > Q:
                      > > > const int* pInt = new int(0);
                      > > > delete pInt;[/color]
                      > >
                      > > Drop the "const". You can't delete a const pointer.[/color]
                      >
                      > Says who?[/color]

                      IIRC MSVC 6 doesn't allow deleting const pointers, even though according
                      to the standard it should.

                      --
                      Peter van Merkerk
                      peter.van.merke rk(at)dse.nl



                      Comment

                      Working...