首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到iostream文件

找不到iostream文件
EN

Stack Overflow用户
提问于 2016-12-17 15:29:13
回答 1查看 2.4K关注 0票数 0

我刚刚开始在C++学习面向对象的知识。在我的第一课中,我收到了错误"iostream文件找不到“。我使用Fedora 24和atom编辑器进行编码。对于构建,我使用命令g++ main.cpp -o a还安装了atom的插件

代码语言:javascript
复制
gpp-compiler

我的主要档案是:

代码语言:javascript
复制
#include <iostream>
#include <string>
#include "BMI.h"

using namespace std;

int main(){
        string name;
        int height;
        double weight;

        cout << "Enter your name: ";
        cin >> name;

        cout << "Enter your height (in inches): ";
        cin >> height;

        cout << "Enter your weight: ";
        cin >> weight;
        BMI a;
        //  BMI Student_1(name, height, weight);

        return 0;
}

当我运行主文件没有BMI对象,它工作。但是当我在主函数中添加BMI对象时,输出就是误差。

我的BMI对象:头文件:

代码语言:javascript
复制
#include <iostream>
#include <string>

using namespace std;

#ifndef BMI_H
#define BMI_H

class BMI {
public:
//Default Constructor
        BMI();
//Overload Constructor
        BMI(string, int, double);
private:
//Member Variable
        string newName;
        int newHeight;
        double newWeight;
};


#endif

CPP文件:

代码语言:javascript
复制
#include "BMI.h"

BMI::BMI(){
  newName = "aa";
  newHeight = 0;
  newHeight = 0.0;
}

BMI::BMI(string name, int height, double weight){
  newName = name;
  newHeight = height;
  newWeight = weight;
}

本教程来自https://www.youtube.com/watch?v=vz1O9nRyZaY

问题是,为什么它不能工作,为什么它没有BMI的物体工作呢?

谢谢,迈克尔。

EN

回答 1

Stack Overflow用户

发布于 2016-12-17 16:21:04

您的cpp文件中有键入错误:

代码语言:javascript
复制
newHeight = 0;
newHeight = 0.0; // <- error

试着:

代码语言:javascript
复制
newHeight = 0;
newWeight = 0.0;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41200135

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档