小编Val*_*ini的帖子

阴影变量

我的问题是关于定义到类中的变量.我告诉你我的问题.

我已经定义了这个类:

class Measure {

int N;
double measure_set[];
char nomefile[];
double T;

public:
    void get( );
    void printall( );
    double mean( );
    double thermal_comp( );
};
Run Code Online (Sandbox Code Playgroud)

我想方法得到以下内容:

  1. 从.dat文件中读取数字并保存到measure_set数组中;
  2. 读取用户输入并将其保存到变量T中;

这就是我所做的:

void Measure::get() 
{   
    cout << "Insert filename:" << endl;
    cin >> nomefile;
    cout << endl;
    cout << nomefile << endl;
    cout << endl;

    int M=0;
    int nmax=50;

    ifstream f;
    f.open(nomefile);
    while(M<nmax)
    {
        f >> measure_set[M];
        if(f.eof()) 
        break;
        M++;
    }
    f.close();
    N=M+1;

    cout << "Insert temperature:" << endl;
    cin >> …
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
6205
查看次数

标签 统计

c++ ×1