Why would you want another constructor ? Since << operator is already overloaded for CComplex, it should be able to handle with the existing generic constructor itself.
If you still want a separate constructor for specific type, implement
i'm using eclipse. Also, could you help me with one problem? In the header file:
1 2 3 4 5 6 7 8 9 10 11 12 13
CXMLString(T content, string tag = "")
{
stringstream mystream;
if (tag.length())
mystream << "<" << tag << ">" << boolalpha << content << "</" << tag
<< ">";
else
mystream << content;
//str() is used for get/set with the associated string
string temp = mystream.str();
this->assign(mystream.str());
//*this = "<" + tag + ">" + temp + "</" + tag + ">";
}
i wanted to overload the constructor for bool passed as string and then the string true/false should be taken and not the numeric 1/0 value. I always ran into errors with another constructor:
1 2 3 4 5 6 7 8 9
CXMLString(bool content, string tag = "")
{
stringstream mystream;
if (content == true)
mystream << "<" << tag << ">" << "true" << "</" << tag << ">";
else
mystream << "<" << tag << ">" << "true" << "</" << tag << ">";
this->assign(mystream.str());
}
so finally used that alphabool keyword for a work around. But assignment specifically tells me to overload the constructor. If you tell me what possibly is wrong here. The errors I'm getting for both the constructors in this case are:
1. error: 'CXML::CXMLString<T>::CXMLString(T, std::string) [with T = bool, std::string = std::basic_string<char>]' cannot be overloaded
2. error: with 'CXML::CXMLString<T>::CXMLString(bool, std::string) [with T = bool, std::string = std::basic_string<char>]'