Pfeffer 2019-11-19 00:27 采纳率: 50%
浏览 212
已结题

C++ 一条程序看不懂,看着并不像是初始化对象

QFile mfile(CONFIG_FILE);// QFile 我们可以读文件,也可以写文件 mfile,nfile 都是无所谓的,名字是随便取得
    if(mfile.exists()){// 确定这个config.init里面是有文件还是没有文件, 初始化对象,动态分配内存
        QSettings *configIniRead = new QSettings(CONFIG_FILE, QSettings::IniFormat); //在堆里面开辟了一块区域,然后把地址赋给栈中的某个地址
        dir_src = configIniRead->value("/main/bak_src").toString();// value 是Qsetting里面的公开方法
        dir_dest = configIniRead->value("/main/bak_dest").toString(); // 配置文件里面有目标地址
        gpg_key = configIniRead->value("/main/gpg_key").toString();
        exclude_from = configIniRead->value("exclude/exclude").toString();
     delete configIniRead; // 与初始化的对象成对出现,会造成内存泄漏   
    }
    else{
        QString err = QString("No file :  %1!").arg(CONFIG_FILE);// 
                exclude_from = "--exclude *.iso --exclude .gvfs/**--exclude .thumbnails/** --exclude .trash/** --exclude .Trash/** --exclude *-gitsvn/** --exclude *-cvs/** --exclude *-svn/** --exclude *-git/** --exclude *-sf/** --exclude *.vc --exclude *.tc --exclude .cache/** --exclude .ccache/** --exclude ./Downloads/** --exclude ./.wine/** --exclude ./Documents/Dropbox/**";
                configFileWrite("exclude/exclude",exclude_from);// 
                outputError(err);// 

QFile mfile(CONFIG_FILE) 这个命令是什么呢,并不是初始化对象,跪求解释一下

  • 写回答

3条回答 默认 最新

  • churuxu 2019-11-19 09:16
    关注

    C++的语法
    类名 变量名(构造参数列表)

    就比如
    string s = "hello";
    string s("hello");
    这两种写法最终得到s变量是一样的

    评论

报告相同问题?

悬赏问题

  • ¥15 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题