Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #7046

Re: call member function without object-compile error

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: call member function without object-compile error
Date Wed, 22 Jun 2011 15:55:59 +1200
Lines 50
Message-ID <96d7euFmtvU5@mid.individual.net> (permalink)
References <26f1f45a-7441-411a-942d-d4e70b853922@j14g2000prn.googlegroups.com> <96d4tjFmtvU4@mid.individual.net> <39a31ad8-bfa6-4cf7-a9e0-64192fdb9cdb@h12g2000pro.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net s5EdDg/GcmQQMVVnlb4hZAPgOswI6h/DSZAFPMcn/oAj6IbooE
Cancel-Lock sha1:xvLGqL5LEAzYH+BaLr3lRjR5MLI=
User-Agent Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4
In-Reply-To <39a31ad8-bfa6-4cf7-a9e0-64192fdb9cdb@h12g2000pro.googlegroups.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:7046

Show key headers only | View raw


On 06/22/11 03:28 PM, eric wrote:
> On Jun 21, 8:12 pm, Ian Collins<ian-n...@hotmail.com>  wrote:
>> On 06/22/11 03:01 PM, eric wrote:
>>
>>> Dear c++ advancer:
>>>     I have a simple c++ file, which is I copy and try to test from a
>>> book (C++ Primer 3rd Ed, by Stanley B. Lippman and Josee Lajoie,
>>> around page 904, chapter 17.3 Base Class Member Access)
>>> the following is my program:
>>
>> <snip for brevity>
>>
>>> -----------------------------
>>> the following is my g++ result(4.5.2)
>>> --------------------
>>> eric@eric-laptop:~/CppPrimer3$ g++ p904.cpp
>>> p904.cpp: In member function bool NameQuery::compare0(const Query*) :
>>> p904.cpp:36:24: error: std::vector<std::pair<short int, short int>    >
>>> Query::_loc is protected
>>> p904.cpp:88:30: error: within this context
>>> p904.cpp: In function int main() :
>>> p904.cpp:96:30: error: cannot call member function bool
>>> NameQuery::compare0(const Query*) without object
>>> eric@eric-laptop:~/CppPrimer3$
>>> --------------------------------------
>>> I just like to know how to fix (88:30) and (96:30)
>>> thanks a lot in advance, Eric
>>
>> For the protected access, provide a public member function to return the
>> vector size.
>>
>> For the call, you have to have an instance of NameQuery to call a
>> non-static member function.
>>
>> As a general point, names starting with leading underscores may clash
>> with names used by your implementation.
>
> Thanks your reply and suggestion
> but after I change leading underscore to a_ (add an "a" in front of
> all _variablename)
> my g++ still response name error : Cann't call memeber function
> without object on (88:30 and 96:30) /* try by yourself */
> so
> still need any advancer's help and suggestion and thanks a lot in
> advance, Eric

What about the other two suggestion to fix your actual problem?

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

call member function without object-compile error eric <cneric12lin0@gmail.com> - 2011-06-21 20:01 -0700
  Re: call member function without object-compile error Ian Collins <ian-news@hotmail.com> - 2011-06-22 15:12 +1200
    Re: call member function without object-compile error eric <cneric12lin0@gmail.com> - 2011-06-21 20:28 -0700
      Re: call member function without object-compile error Ian Collins <ian-news@hotmail.com> - 2011-06-22 15:55 +1200
        Re: call member function without object-compile error eric <cneric12lin0@gmail.com> - 2011-06-21 21:36 -0700
          Re: call member function without object-compile error Ian Collins <ian-news@hotmail.com> - 2011-06-22 16:43 +1200
            Re: call member function without object-compile error eric <cneric12lin0@gmail.com> - 2011-06-21 21:54 -0700

csiph-web