2011-09-13 38 views
1

我有下面的構造:沒有匹配的功能 - C++

RegMatrix(int numRow, int numCol, std::vector<double> fill); 

和裏面的我的功能之一:

RegMatrix RegMatrix::operator+(RegMatrix &matrix) 

創建:

std::vector<ThreeDigits> fill; 

,然後我回:

return RegMatrix(1,2,fill); 

它說我回來(int,int,std::vector<ThreeDigits>&) ...
這是爲什麼,我該如何解決它?

+0

你是什麼意思「它說我返回std :: vector&」?什麼是確切的錯誤信息? –

+0

調用RegMatrix :: RegMatrix時沒有匹配的函數(int,int,std :: vector &) –

+0

什麼是'ThreeDigits'? –

回答

4

std::vector<double>std::vector<ThreeDigits>不是一樣的類型。您可以通過創建RegMatrix::RegMatrix(int, int, const std::vector<ThreeDigits>&)或修改fill的聲明來修復此問題:std::vector<double> fill;

+6

除非'ThreeDigits'碰巧是'double'的typedef。 –

+1

..即使存在從「double」到「ThreeDigits」的隱式轉換,這並不意味着存在從「向量」到「向量」的隱式轉換。 –