Question
My program cannot display the output. Please correct any errors that I have in C++. TEXT FILE 321 Jimmy 232 Holly 551 Billy 626 Tony
My program cannot display the output. Please correct any errors that I have in C++.
TEXT FILE
321 Jimmy 232 Holly 551 Billy 626 Tony 975 David
HEADER FILE
#include
#include
#include
using namespace std;
#ifndef student_h
#define student_h
class student
{
public:
student();
student(string file);
void printstudent(string x);
private:
string filename;
int id[100];
string name[100];
};
student::student()
{
filename = " ";
for (int i = 0; i
{
name[i] = " ";
}
for (int i = 0; i
{
id[i] = 0;
}
}
student::student(string file)
{
filename = file;
fstream inputfile;
inputfile.open(filename);
while (!inputfile.eof())
{
for (int i = 0; i
{
inputfile >> name[i] >> id[i];
}
}
}
void student::printstudent(string x)
{
for (int i = 0; i
{
if (x == name[i])
{
cout
}
}
}
#endif
CPP FILE
#include
#include
#include
#include "student.h"
using namespace std;
int main()
{
string x;
student mystudent ("class.txt");
cout
cin >> x;
mystudent.printstudent(x);
system("pause");
return 0;
}
#include #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started