c++ - Template classes and their methods -


Adding my program creates a bunch of errors as below.

  / home / starlon / projects / LCD control / docctpp: 8: `generic & lt; LCDText> gt; :: Undefined context for generic (jsn :: value *, at) '/home/starlon/Projects/LCDControl/DrvQt.cpp18`generic & lt; LCDText & gt; :: ~ Generic () '/ Homes / Starlon / Project / LCDCDrol / DRUVT CPP: 8:' Generic & lt; LCDTST & gt; :: Generic (Jason :: Value *, Int) '/ Home / StarLon / Projects / LCD Control / DoccPPP: 18:' Generic and LT; LCDTX & gt; :: Generic () 'Undefined reference in the context of' DQ.T.O: Function `~ DOCQ ': / Homes / Starlane / Project / LCD Control / DRUVT CPP: 23:' Generic & lt; LCDTST & gt; Undefined context for: ~ generic () '/home/starlon/Projects/LCDControl/DrvQt.cpp:23': Generic & lt; LCDText> Undefined context of: / generic () '/ home /starlon/Projects/LCDControl/DrvQt.cpp:23: `General & lt; LCDText> Undefined reference to: ~ generic () '/home/starlon/Projects/LCDControl/DrvQt.cpp:23': undefi `generic & lt; LCDText> :: ~ Generic () 'Dowie.O.O. :( Regarding Rodata._ZTV5DrvQt [Vtebel for Dowquit] + 0xc): `Generic & lt; LCDTST & gt; :: Undefined context in terms of 'CFG_Key ()' 'DrvQt.o :(. Rodata._ZTC5DrvQt0_7GenericI7LCDTextE [vvtable for drvQt] + 0xc): `Generic & lt; LCDTET> gt; :: Undefined context for CFG_Key () ''  

This means that I should be a generic:: MethodName (and generic :: methodname) for each template parameter I'm going to use Am I I hope not. I was under the impression that the template should have avoided this kind of scenario.

Edit: Here's DWPPPP

  #include & lt; Iostream & gt; # Include & lt; QMainWindow & gt; Include # "DrvQt.h" DrvQt.h # DrvQt :: DrvQt (LCD control * Visitor, Jason :: Value * Config, Int Rows, Ent Calls) Include: Generic & lt; LCDText> (config, LCD_TEXT) {// line 8 display_ = new QtDisplay (generic & lt; LCDText> gt; *) this, config, rows, columns, 8, 6); LCD_ = (LCD text *) display_; Std :: cout & lt; & Lt; "Dowquitz" & lt; & Lt; Std :: endl; Visitor_ = visitor; Std :: cout & lt; & Lt; "Eval:" & lt; & Lt; Eval ("uptime.Uptime ('% H')"). ToString () ToStdString () & lt; & Lt; Std :: endl; Std :: cout & lt; & Lt; "Eval:" & lt; & Lt; Evil ("cpuinfo.CpuInfo ('Model Name')"). ToString () ToStdString () & lt; & Lt; Std :: endl; Std :: cout & lt; & Lt; "Eval:" & lt; & Lt; Evil ("Foo"). ToString () ToStdString () & lt; & Lt; Std :: endl; Std :: cout & lt; & Lt; "Eval:" & lt; & Lt; Evil ("name"). ToString () ToStdString () & lt; & Lt; Std :: endl; } // line 18 dowety :: ~ dovctit () {delete_ display_; // delete window; } // line 23  

More code for debug, please post some code Please do not have enough debug messages (at least for me).

For now, it seems like an undefined reference so that you can ensure that the template class declaration and implementation is not different in the same file as a .hpp and .cpp in general This template is class There is a lack of (after understanding this, once understood how they work).

Edit: How do you want to use the template class in other files?

I mean you have (in the general project):

  someclass.hpp someclass.cpp main.cpp  

And then you have to merge all the classes to a certain class after implementing a template class in some top class header files, so that it is now:

  someclass Hpp main.cpp  

In both cases, you can also include "# someclass.hpp" in the main.cpp file, and you can gain access to that class both times.

See paragraph below for more information.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -