inheritance - protected function call c++ -


class base() { protected:     void foo(); } class derived : public base {     void bar(); }  void derived::bar(){     foo();    //this causes error. } 

i know i'm missing obvious i've been going round in circles hour. how call protected function in derived class?

the error appears in comments linker error, have checked that:

it's hard tell more without more info.


also, code contains invalid syntax, causes error(s):

  • class lower case
  • no brackets after class name
  • ; after class definition

the following code works (until gets linker) on g++ version 4.9.0:

class base { protected:     void foo(); };  class derived : public base {     void bar(); };  void derived::bar(){     foo(); } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -