1

how to overload + operator in template in c++. My code-> i understand operator overloading in general, but problem with template

template<class T> class type
{
    template <class X>type& operator+(const type& abc)
    {
        cout<<this+abc<<endl;
    }
};
  • 1
    Does this answer your question? [What are the basic rules and idioms for operator overloading?](https://stackoverflow.com/questions/4421706/what-are-the-basic-rules-and-idioms-for-operator-overloading) and then make it a non-member friend template function. See `std::string::operator+` for an example https://en.cppreference.com/w/cpp/string/basic_string/operator%2B – Richard Critten Nov 30 '19 at 13:35
  • I can not understand, there is no template parameter passed – vishwatmasandeep Nov 30 '19 at 13:38
  • i understand operator overloading in general, but problem with template – vishwatmasandeep Nov 30 '19 at 13:39

0 Answers0