Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #7044
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: call member function without object-compile error |
| Date | 2011-06-22 15:12 +1200 |
| Message-ID | <96d4tjFmtvU4@mid.individual.net> (permalink) |
| References | <26f1f45a-7441-411a-942d-d4e70b853922@j14g2000prn.googlegroups.com> |
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