c++ - One method for doing the same with different variables -
i have that
class foo { bar a, b, c; void dostuffwitha(); void dostuffwithb(); void dostuffwithc(); } instead of writing implementation each of methods want template. how that?
cheers, dirk
edit:
i explicitly need know variable stuff (recursion):
class foo { bar a, b, c; foo* parent; static void dorecursivestuffwitha(foo *_node) { if(_node->parent==null) { return; } else { dorecursivestuffwitha(_node->parent) } } static void dorecursivestuffwithb(foo *_node) { if(_node->parent==null) { return; } else { dorecursivestuffwithb(_node->parent) } } static void dorecursivestuffwithc(foo *_node) { if(_node->parent==null) { return; } else { dorecursivestuffwithc(_node->parent) } } } edit2:
maybe explain better problem is:
class foo { public: int a, b, c; } class bar { public: void dostuffwithaoffoo(foo *_foo); void dostuffwithboffoo(foo *_foo); void dostuffwithcoffoo(foo *_foo); } i want keep code simple , not have implement dostuffwithx 3 times...
i think want parameters...
class foo { bar a, b, c; void dostuffwithbar(bar x); } templates dealing variety of data-types , function arguments dealing variety of variables.
Comments
Post a Comment