c++ - argument list for class template "Complex" is missing -


i have isequalto function comparison of several data types through use of templates. when first had in main.cpp file well, once split complex class it's header , it's cpp file i'm getting error stating, "argument list class template "complex" missing". of course check default constructor class complex , here is:

**main.cpp**  #include <iostream> #include <string>   objects #include "complex.h" using namespace std;   template <class t>       class complex<t> bool isequalto(t a, t b)         {     if(a==b)     {     cout << << " equal " << b << endl;     return true;     } else cout << << " not equal " << b << endl; return false; }  int main() {     //comparing complex class complex<int> complexa(10, 5), complexb(10, 54), complexc(10, -5), complexd(-10, -5);        //creating complex class objects cout << endl << endl << "******comparing complex objects:****** \n"; isequalto(complexa, complexa);      //true isequalto(complexa, complexb);      //false isequalto(complexc, complexa);      //false isequalto(complexd, complexd);      //true }    **complex.h** #ifndef complex_h #define complex_h #include <iostream> using namespace std;  template <class t> class complex {   public:     //default constructor class complex     complex(int realpart, int imaginarypart) : real(realpart), imaginary(imaginarypart)       //overloading equality operator      bool operator==(const complex &right) const     //address of our cosnt right operand have 2 parts complex data type, real , imaginary     {         return real == right.real && imaginary==right.imaginary;        //returns true if real equal both of parts right.real , right.imaginary     }       //overloading insertion operator     friend ostream &operator<<(ostream&, complex<t>&);   private:    //private data members class complex     int real;       //private data member real     int imaginary;  //private data member imaginary };  #endif  **complex.cpp**  #include "complex.h" #include <iostream>; using namespace std;  template<class t> ostream &operator<<(ostream& os, complex,t.& obj) { if(obj.imaginary > 0)//if our imaginary object greater 0     os << obj.real << " + " << obj.imaginary << "i";         else if (obj.imaginary == 0)    //if our imaginary object 0     os << obj.real; //then our imaginary not exist insert real part else    //if no other condition true imaginary must negative therefor {     os << obj.real << obj.imaginary << "i";     //insert real , imaginary } return os;      //return ostream object  } 

complex template class. needs template argument when constructed.

complex<int> complexa(10, 5);         ^^^^  

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -