-1
我创建了一个类文件“Heuristic.hpp”,定义如下:错误:候选构造函数(隐式转移构造函数)并不可行:没有已知的转换
#include <iostream>
#include <vector>
#include <chrono>
#include <cstdint>
#include <cmath>
#include <limits>
#include "csv.hpp"
#include "mdl.hpp"
class Computation {
public:
Computation(const int n,const int noRows, MDL mdl) {
std::cout << "Constructor successfully made" << std::endl;
}
double heuristic() {
return 0;
}
private:
std::vector<uint64_t> MDL_RawIndex_;
std::vector<std::vector<uint64_t>> factValues_;
std::vector<std::vector<uint64_t>> MDL_Index_;
std::vector<std::vector<double>> MDL_RawScore_;
std::vector<std::vector<double>> MDL_Score_;
std::vector<uint64_t> MDL_Score_Length_;
std::vector<double> bestScore_;
int n_ = 0;
int noRows_ = 0;
};
和主代码文件“的例子.cpp“当我尝试创建对象时,它会抛出我的错误。代码如下:当我尝试创建在前一个文件中声明的类Computation的对象时出错。构造函数的心不是被称为在这种情况下:
#include <iostream>
#include <vector>
#include "csv.hpp"
#include "mdl.hpp"
#include "Heuristic.hpp"
Computation bootup() {
std::string in = "/Users/skx/Google Drive/Semester3_Fall15/CSE603/HeuristicSearchPy/child.csv";
int noRows = 4000;
std::vector<signed char> Data;
int n = 20;
if (!read_csv(in, n, noRows, Data)) {
std::cout << "error: could not read input" << std::endl;
return -1;
}
MDL mdl(n, noRows, Data);
Computation h(n,noRows,mdl); //This object creation is where error is occurring
return h;
}
int main(int argc,char* argv[]) {
return 0;
}
错误日志:
note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'Computation &&' for 1st argument
class Computation {
^
/Users/skx/Google Drive/Semester3_Fall15/CSE603/HeuristicSearchPy/Heuristic.hpp:11:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const Computation &' for 1st argument
class Computation {
请显示完整的错误信息。 – Ionut
是应该构建的'Computation'或'MDL'吗? –
计算必须构造(导致错误),MDL已构建(工作正常) – letsBeePolite