私は小さなアプリケーションを作成しようとしており、auto_ptrを使ってコンパイル時エラーが発生しました。ISO C++で型なしの 'auto_ptr'宣言が禁じられています
私が作成したクラスでスマートなポインタを作成するのはもともと疲れましたが、タイプがint型のスマートポインタを作成しようとすると同じエラーが発生します。私はhere.与えられた例に従っていた。
私は自分自身を叩いてしまう結果になると感じています。
スマートポインタをこのファイルの末尾に宣言します。
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <memory.h>
#include <QMainWindow>
#include "dose_calac.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
/*
Some QT stuff here, removed for clarity/size...
*/
private:
Ui::MainWindow *ui;
/*
Object for storage of data and calculation of DOSE index score.
*/
std::auto_ptr<int> pdoseIn(new int); // A simple set case, but sill produces an error!?!
std::auto_ptr<DOSE_Calac> pdoseIn(new DOSE_Calac); // Original code, error found here at first.
};
#endif // MAINWINDOW_H
これは私のクラス、dose_calac.hです。
#ifndef DOSE_CALAC_H
#define DOSE_CALAC_H
class DOSE_Calac
{
public:
// constructor
DOSE_Calac();
// set and get functions live here, removed for clarity/size.
// function for caulating DOSE indexpoints
int CalcDOSEPoints();
private:
unsigned int dyspnoeaScale;
unsigned int fev1;
bool smoker;
unsigned int anualExacerbations;
unsigned int doseIndexPoints;
};
#endif // DOSE_CALAC_H
喜んでいただいた助けや提案。
サイドノート: 'auto_ptr'はC++ 11では非推奨です。 – iammilind