Re: Passing "classtype" as "this" argument of "class member function"

Discussion in 'C++' started by Frank Schmitt, Oct 14, 2003.

  1. wyldhoney <> writes:

    Please don't post HTML to this NG (it seems only the header is HTML).
    And please, don't waste space by inserting dozens of empty lines -
    rearranged.

    > I wrote a custom Polynomial class with one private member (a custom
    > Array class).
    > Compiling my polynomial.cc file gives me this error message:
    >
    > polynomial.cc:26: passing `const Safe_Array' as `this' argument of `int
    > Safe_Array::size()' discards qualifiers
    >
    > Any ideas on what I'm doing wrong?


    please post compilable code next time - guessing your error without the
    source code is impossible most of the time (except for this time :)

    you are calling the size() member function on a const Safe_Array object
    - since size() isn't declared const, you aren't allowed to do that.
    Your options are:
    - omit the const on your Safe_Array object
    - declare size() const (probably the better idea, since it shouldn't
    change the object, should it?)

    HTH & kind regards
    frank

    --
    Frank Schmitt
    4SC AG phone: +49 89 700763-0
    e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com
    Frank Schmitt, Oct 14, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil Winstanley [Microsoft MVP ASP.NET]

    Re: validateRequest=&quot;false&quot; not working in web.config or page directive

    Phil Winstanley [Microsoft MVP ASP.NET], May 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    634
    Phil Winstanley [Microsoft MVP ASP.NET]
    May 16, 2004
  2. usr2003
    Replies:
    4
    Views:
    576
    usr2003
    Sep 19, 2003
  3. Ahti Legonkov
    Replies:
    0
    Views:
    496
    Ahti Legonkov
    Dec 12, 2003
  4. Leslaw Bieniasz
    Replies:
    1
    Views:
    325
    mlimber
    Apr 5, 2006
  5. =?ISO-8859-1?Q?Szabolcs_Horv=E1t?=
    Replies:
    4
    Views:
    486
    Daniel T.
    Oct 28, 2006
Loading...

Share This Page