Calling parent function
i trying implement call parent class function without success.
the base class :
then child needs declare parent :
but in order child see base , must include base class in child (other wise error not know base)
but
(error on line child *children; saying unknown type name child" ).
how can resolve ?
the base class :
code: [select]
class base
{
public:
base();
child *children;
float thedelegate(char *arg);
then child needs declare parent :
code: [select]
class child: public base
{
public:
...
but in order child see base , must include base class in child (other wise error not know base)
but
code: [select]
#include "base.hpp"
, cause error on base, since include each other.(error on line child *children; saying unknown type name child" ).
how can resolve ?
(error on line child *children; saying unknown type name child" ).check capilatization, unless typed memory , didn't copy+paste.
do have include guards in header files? must reason.
children not have derived type of parent. little less abstraction , lit more specifics can use see if example of x-y problem.
you must include base.hpp in child.hpp, not include child.hpp in base.hpp. add forward declaration of child class above base class in base.hpp:
code: [select]
class child;
that's it.
Arduino Forum > Using Arduino > Programming Questions > Calling parent function
arduino
Comments
Post a Comment