我将vector
传递给对象中的函数时遇到问题。
我的vector
class PrintRectangle : public QWidget
{
Q_OBJECT
public:
explicit PrintRectangle(QWidget *parent = 0);
public:
teacher *tech;
bool clicked[5][5] = {};
std::vector<std::vector<perceptron>> p;
}
实施
PrintRectangle::PrintRectangle(QWidget *parent) : QWidget(parent),
p(5, std::vector<perceptron>(5))
{
tech = new teacher(clicked);
for(int i=0; i<5; i++)
{
for(int j=0; j<5; j++)
{
p[i][j].randweight();
}
}
double learnConst = 0.1;
tech->learnPerceptrons(p);
}
我在tech->learnPerceptrons(p);
E:\Sieci Neuronowe\Perceptron\printrectangle.cpp:20: error: no matching function for call to 'teacher::learnPerceptrons(std::vector<std::vector<perceptron> >&)'
tech->learnPerceptrons(p);
^
我在teacher
类
void learnPerceptrons(std::vector<std::vector<perceptron>> &p)
问题出在哪里?我应该以不同的方式创建teacher
类的对象吗?
所有错误:
../../Sieci Neuronowe/Perceptron/printrectangle.cpp: In constructor 'PrintRectangle::PrintRectangle(QWidget*)':
../../Sieci Neuronowe/Perceptron/printrectangle.cpp:19:29: error: no matching function for call to 'teacher::learnPerceptrons(std::vector<std::vector<perceptron> >&)'
tech->learnPerceptrons(p);
^
In file included from E:/Sieci Neuronowe/Perceptron/printrectangle.h:6:0,
from ../../Sieci Neuronowe/Perceptron/printrectangle.cpp:1:
E:/Sieci Neuronowe/Perceptron/teacher.h:20:10: note: candidate: void teacher::learnPerceptrons(std::vector<std::vector<teacher::perceptron> >&)
void learnPerceptrons(std::vector<std::vector<perceptron>> &p);
^
E:/Sieci Neuronowe/Perceptron/teacher.h:20:10: note: no known conversion for argument 1 from 'std::vector<std::vector<perceptron> >' to 'std::vector<std::vector<teacher::perceptron> >&'
../../Sieci Neuronowe/Perceptron/printrectangle.cpp:17:12: warning: unused variable 'learnConst' [-Wunused-variable]
double learnConst = 0.1;
^
Makefile.Debug:833: recipe for target 'debug/printrectangle.o' failed
mingw32-make[1]: Leaving directory 'E:/nienazwany/build-nienazwany-Desktop_Qt_5_7_0_MinGW_32bit-Debug'
mingw32-make[1]: *** [debug/printrectangle.o] Error 1
答案 0 :(得分:1)
您在帖子中提到:
我在老师班的功能定义
void learnPerceptrons(std :: vector&gt;&amp; p)
但是,您的teacher class on github有void learnPerceptrons(perceptron * (&array)[5][5]);
方法,而不是learnPerceptrons(std::vector<std::vector<perceptron>> &p)
....这一定是问题......
答案 1 :(得分:0)
错误日志显示perceptron
也在teacher
声明:
E:/Sieci Neuronowe/Perceptron/teacher.h:20:10: note: no known conversion for
argument 1 from 'std::vector<std::vector<perceptron> >' to 'std::vector<std::vector<teacher::perceptron> >&'
此perceptron
在learnPerceptrons()