注册 登录
编程论坛 C++教室

C++为什么不能在类中使用ifstream,要怎么修改才可以使用?

a1017075043 发布于 2018-05-18 16:03, 1523 次点击
程序代码:
#ifndef CIRCLE_H
#define CIRCLE_H

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

ifstream=ifstream;

class ReadNginxConfig
{
private:

public:
    string ConfigPath;
    string Config[1000];
    ReadNginxConfig(string ConfigPath);
    string getConfigPath();
    void ReadDataFromFileWBW();
};
//构造函数
ReadNginxConfig::ReadNginxConfig(string ConfigPath)
{
    this->ConfigPath=ConfigPath;
}
//返回配置文件路径
string ReadNginxConfig::getConfigPath()
{
    return this->ConfigPath;
}
//读取方式: 逐词读取, 词之间用空格区分
void ReadNginxConfig::ReadDataFromFileWBW()
{
    //cout<<"逐词读取, 词之间用空格区分"<<endl;
   
    ifstream fin(ConfigPath);
}
1 回复
#2
Jonny02012018-05-19 11:14
ifstream fin;
ifstream fin = ifstream("ConfigPath");

ifstream 的构造函数
basic_ifstream();
explicit basic_ifstream( const char* filename,
                std::ios_base::openmode mode = ios_base::in );


还有你上面那句
ifstream=ifstream;
是什么鬼?
1