Question: Learning C++ here. So I have written: #include #include #include using namespace std; class BMI { private: double weight; int height; string name; public: BMI()

Learning C++ here.

So I have written:

#include #include #include

using namespace std;

class BMI { private: double weight; int height; string name; public: BMI() {} BMI(string name, double weight, int height) { this->weight = weight; this->height = height; this->name = name; } void setWeight(double weight) { this->weight = weight; } double getWeight() const { return weight; } void setHeight(int height) { this->height = height; } int getHeight() const { return height; } void setName(string name) { this->name = name; } string getName() const { return name; } };

void fillVector(vector& students); void printVector(const vector& students);

int main() { vector Students; fillVector(Students); printVector(Students); }

void fillVector(vector& students) { double weight; int height; string name; cout << "Enter Student information" << endl; cout << "Enter name: "; cin >> name; cout << "Enter weight: "; cin >> weight; cout << "Enter height: "; cin >> height; for (int i = 0; i < students.size(); i++) { BMI Students(name, weight, height); students.push_back(Students); cout << endl; } cout << endl; }

void printVector(const vector& students) { for (int i = 0; i < students.size(); i++) { cout << "Name: " << students[i].getName() << endl; cout << "weight: " << students[i].getWeight() << endl; cout << "height: " << students[i].getHeight() << endl; } }

I can enter stuff in but It would not print the values i put in.

Let me know what i did wrong. please help.

Thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!