c++ - using a conditional type in a .cpp file -
I have a templated class and a type that depends on the template. How can I use this in my CCP file?
object.hpp:
pair_d = std :: pair and lt; Double, double> Pair_f = std :: pair & lt; Float, float & gt; Template & lt; Typename T & gt; Class Object {Public: Static_AstTort (Study :: ISIm ; value; std :: is_same : value, "type is not allowed"); Pair = typename std :: conditional & lt; Std :: is_same & lt; T, float & gt; :: value, pair_f, pair_d & gt; :: By typing; // conditional type const pair doSomething (T, T) function using const; } object.cpp
#include "object.hpp" template & lt; Typename T & gt; Const pair object & lt; T & gt; :: doSomething (TT1, TT2) const {// ....} but I'm getting:
Error: Unknown type name 'pair'
How can I use the 'pair' type in my .cpp file?
-
Arguments have been named with the same name (t T, TT) , separate those names. -
Do not do this, you have divided the template declaration / definition into CPP and a header file.
-
-
You forgot about a const qualification on a return type in the definition (which is in the declaration). -
You are not a typename keyword for a dependent name. Your definition should be:
template & lt; Typename T & gt; Const typame object & lt; T & gt; :: Pair object & lt; T & gt; :: doSomething (TT1, TT2) const {// stuff} or (to avoid the dependent name):
template & Lt; Typename T & gt; Auto Object & lt; T & gt; :: doSomething (TT1, TT2) const - & gt; Const pair {// stuff}
c ++ प्रोग्रामिंग सैंपल कोड
ReplyDeleteC ++ भाषा में tictactoe गेम