私はclass
を持っています。これは基本的に別のオブジェクトへのポインタの2D matrix
のラッパーです。vectors
です。私class
のデストラクタが呼び出されるたびに、いくつかの理由 ポインタのベクトル行列を持つオブジェクトのデストラクタを呼び出すときにプログラムがクラッシュする
nullptr
をしている場合でも、
delete
ポインタにしようとしているように思えます。
のcppファイル:
RotationSolution.h
:
#ifndef PUZZLESOLVER_ROTATIONSOLUTION_H
#define PUZZLESOLVER_ROTATIONSOLUTION_H
#include <vector>
#include <fstream>
#include "PuzzlePiece.h"
using namespace std;
class RotationSolution {
private:
int _height, _width;
vector<vector<PuzzlePiece*>> _matrix;
public:
RotationSolution();
RotationSolution(int height, int width);
vector<PuzzlePiece*>& operator[](int row);
int get_height() const;
int get_width() const;
};
#endif //PUZZLESOLVER_ROTATIONSOLUTION_H
RotationSolution.cpp:
#include "RotationSolution.h"
vector<PuzzlePiece*>& RotationSolution::operator[](int row) {
return _matrix[row];
}
RotationSolution::RotationSolution() : RotationSolution(0, 0) {}
RotationSolution::RotationSolution(int height, int width) :
_height(height), _width(width), _matrix(vector<vector<PuzzlePiece*>>(_height, vector<PuzzlePiece*>(_width, nullptr)))
{}
int RotationSolution::get_height() const {
return _height;
}
int RotationSolution::get_width() const {
return _width;
}
ここ
は私.h
と.cpp
ファイルです0
コードは、実際にこのようなセクションにクラッシュさ:_sol = RotationSolution(height, length);
ラインにおける第2の反復において
for (auto length: _rowLengths) {
auto height = size/length;
_sol = RotationSolution(height, length);
...
}
。
私は任意のnoobのミスを許してくださいc++
に新しいまだ午前:
デバッグ、コードがクラッシュ信号が(LIBファイルをしている私はかなり確信している)new_allocator.h
からである送信します悪い習慣:)
なぜdownvoteですか?不足しているものがあるかどうか教えてください –
すべてのコードを貼り付けていませんでしたか?あなたはデストラクタを持っていません。どのようにそこにクラッシュすることができますか? – nvoigt
[mcve]を投稿してください。 – nvoigt