Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #7044
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!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:12:35 +1200 |
| Lines | 36 |
| Message-ID | <96d4tjFmtvU4@mid.individual.net> (permalink) |
| References | <26f1f45a-7441-411a-942d-d4e70b853922@j14g2000prn.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net wGDHZEQNWR5zzSlJf2cDIQyzEmXqyGr9iZhumQrCZzXeP/k/tH |
| Cancel-Lock | sha1:OdYFITHRgJfQLmh2SuqiWXsz97c= |
| 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 | <26f1f45a-7441-411a-942d-d4e70b853922@j14g2000prn.googlegroups.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:7044 |
Show key headers only | View raw
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. -- Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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