【发布时间】:2021-11-13 01:54:22
【问题描述】:
所以,我正在处理一个项目,我在这个项目中有两个文件: main.cpp、matrix.h
问题是我的代码在几个小时前似乎可以正常工作,现在却不行了
main.cpp:
#include <iostream>
#include "matrix.h"
#include <vector>
int main() {
Matrix f;
f.create(10, 1, {3, 4, 5, 6, 7, 8, 9});
}
矩阵.h:
#pragma once
#include <iostream>
#include <string>
#include <Windows.h>
#include <vector>
class Matrix {
public:
const size_t N;
bool ifMatrixCreated;
const char* NOTENOUGH = "The size of the array should match to the width*height elements";
std::vector<int> arr;
int w, h;
void create(int width, int height, const std::vector<int> a) {
w = width;
h = height;
if (a.size() != width * height) {
ifMatrixCreated = false;
std::cout << "bello";
}
else {
ifMatrixCreated = true;
arr = a;
std::cout << "hello";
}
}
};
当我编译时,它会产生这个错误(使用 VS2019):
Error C2280 | 'Matrix::Matrix(void)': attempting to reference a deleted function Matrix | Line 5
老是说“Matrix的默认构造函数不能被引用——它是一个被删除的函数”
你能帮忙解决这个错误吗?
提前致谢。
【问题讨论】:
标签: c++ visual-studio compiler-errors visual-studio-2019