2013-03-17 1 views
0

나는 내가 정의한 객체에 추가하려고하는 복소수 벡터를 작성합니다. 문제는 내 vector<double>이 어떻게 든 vector<double, allocator<double>>으로 변환되고 있다는 것입니다. 왜 누군가는 볼 수 있습니까?벡터 <double>이 벡터 <double로 변환되는 경우, 할당 자 <double>>

no matching function for call to generatorTemplate::generatorTemplate(std::string&, std::vector<double, std::allocator<double> >&......

+0

질문 본문에 설명을 수정했습니다. 불완전한 wrt/subject 인 것 같습니다. – wilx

+1

실제로 문제를 재현하는 코드를 게시해야합니다. – juanchopanza

답변

4

std::vector<T> 사실 template < class T, class Alloc = allocator<T> > class vector;에 내 객체에 추가 할 때

#include <iostream> 
#include <fstream> 
#include <sstream> 
#include <string> 
using namespace std; 

double stringToDouble(const std::string& s) 
{ 
    std::istringstream i(s); 
    double x; 
    if (!(i >> x)) 
    return 0; 
    return x; 
} 

int main() { 
    ifstream userDefine("userDefine.csv"); 
    string token, line; 
    stringstream iss; 
    int count = 0; 
    vector<double> prices; 

    while (getline(userDefine, line)) 
    { 
     iss << line; 
     while (getline(iss, token, ',')) 
     { 
      double temp = stringToDouble(token); 
      prices.push_back(temp); 
     } 
    } 
    return 0; 
} 

그런 다음 나는 다음과 같은 오류가 발생합니다. 보시다시피 할당 자 유형 매개 변수에는 기본값이 있습니다. 당신이 관찰하고있는 것이 기대됩니다. 거기에 아무런 문제가 없습니다.