0
C++でObject Orientedを学び始めました。 私の最初のレッスンで、そのエラー"iostreamファイルが見つかりません"を受け取りました。 私は、コーディングのためにFedora 24とアトムエディタを使用します。私はコマンドg++ main.cpp -o a
ことを使用したビルドのために 私もインストール原子のプラグインiostreamファイルが見つかりません
gpp-compiler
私の主なファイルは次のとおりです。
#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オブジェクトなしでメインファイルを実行したとき。 しかし、main関数にBMIオブジェクトを追加すると、出力はエラーになります。
私のBMIオブジェクト: ヘッダファイル:
#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ファイル:
#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オブジェクトなしで動作しますか?
ありがとう、マイケル。
? – StoryTeller
おそらく、学習する最良の方法は本を読むことです。ここには[C++の本](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)の素敵なリストがあります。 –
g ++ main.cpp -oa出力は/tmp/ccM9rMj9.oです。関数mainにあります。 main.cpp :(。テキスト+ 0x7d):未定義のBMI :: BMI()への参照 collect2:エラー:ldが1の終了ステータスを返しました –