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

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -