C++ design issue. New to templates -


i'm new c++ templates.

i have class constructor takes 2 arguments. it's class keeps list of data -- it's list of moves in chess program.

i need keep original class it's used in other places, need pass arguments class, , in doing have few private data members , specialize 1 of private methods -- else stay same. don't think derived class helps me here, aren't going similar objects, , private methods called constructor , call virtual method of base class -- not derived method.

so guess templates going answer. looking hints how might proceed.

thanks in advance

your guess wrong. templates no more answer problem inheritance is.

as jtbandes said in comment below question, use composition.

create class contains instance of existing class member. forward or delegate operations contained object needed (i.e. member function in new class calls member functions of contained object). add other members needed, , operations work them.

write new code interact new class. when new code needs interact old code, pass contained object (or reference or pointer it) needed.

you might choose implement container template, implementation choice, , depends on how wish reuse container.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -