如何編寫模板類的拷貝構造函數。所以如果模板參數是另一個用戶定義的類,它的拷貝構造函數也被調用。如何寫模板類拷貝構造函數
以下是我的課
template <typename _TyV>
class Vertex {
public:
Vertex(_TyV in) : m_Label(in){ }
~Vertex() { }
bool operator < (const Vertex & right) const {
return m_Label < right.m_Label;
}
bool operator == (const Vertex & right) const {
return m_Label == right.m_Label;
}
friend std::ostream& operator << (std::ostream& os, const Vertex& vertex) {
return os << vertex.m_Label;
}
_TyV getLabel() { return m_Label;}
private:
_TyV m_Label;
public:
VertexColor m_Color;
protected:
};
你想擁有可以接受任何'class'作爲參數的拷貝構造函數嗎? – iammilind
@iammilind:那不會是複製構造函數。 –