#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<iomanip>
using namespace std;
class Course
{
private:
long CourseNum;
string CourseName;
public:
Course();
Course(long cNum,string cName);
};
class Person
{
private:
long SSN;
string Fname;
string Lname;
long Age;
char Gender;// (‘M’ for Male and ‘F’ for Female)
public:
Person();
Person(long ID,string Fn,string Ln,long A,char G);
};
class Student
{
private:
long StNo;
Course Course1;
Course Course2;
Course Course3;
public:
Student();
Student(long SN,Course C1,Course C2,Course C3);
};
class StudentProfile
{
private:
Person PersonalInfo;
Student StdInfo;
Hi everyone. I couldn't read data for course number and course name of each one in data3.txt. Could you tell me how can I fix that? Appreciate your help!
classPrivate.cpp: In member function ‘void StudentCollection::getPeople()’:
classPrivate.cpp:110:44: error: ‘class Student’ has no member named ‘cNum’
while(fin>>num>>ID>>Fn>>Ln>>A>>G>>SN>>C1.cNum>>C1.cName>>C2.cNum>>C2.cName>>C3.cNum>>C3.cName)
^
classPrivate.cpp:110:53: error: ‘class Student’ has no member named ‘cName’
while(fin>>num>>ID>>Fn>>Ln>>A>>G>>SN>>C1.cNum>>C1.cName>>C2.cNum>>C2.cName>>C3.cNum>>C3.cName)
^
classPrivate.cpp:110:63: error: ‘class Student’ has no member named ‘cNum’
while(fin>>num>>ID>>Fn>>Ln>>A>>G>>SN>>C1.cNum>>C1.cName>>C2.cNum>>C2.cName>>C3.cNum>>C3.cName)
^
classPrivate.cpp:110:72: error: ‘class Student’ has no member named ‘cName’
while(fin>>num>>ID>>Fn>>Ln>>A>>G>>SN>>C1.cNum>>C1.cName>>C2.cNum>>C2.cName>>C3.cNum>>C3.cName)
^
classPrivate.cpp:110:82: error: ‘class Student’ has no member named ‘cNum’
while(fin>>num>>ID>>Fn>>Ln>>A>>G>>SN>>C1.cNum>>C1.cName>>C2.cNum>>C2.cName>>C3.cNum>>C3.cName)
^
classPrivate.cpp:110:91: error: ‘class Student’ has no member named ‘cName’
while(fin>>num>>ID>>Fn>>Ln>>A>>G>>SN>>C1.cNum>>C1.cName>>C2.cNum>>C2.cName>>C3.cNum>>C3.cName)
^
classPrivate.cpp:112:46: error: ‘class Student’ has no member named ‘cNum’
StudentProfile p1(num,ID,Fn,Ln,A,G,SN,C1.cNum,C1.cName,C2.cNum,C2.cName,C3.cNum,C3.cName);
^
classPrivate.cpp:112:54: error: ‘class Student’ has no member named ‘cName’
StudentProfile p1(num,ID,Fn,Ln,A,G,SN,C1.cNum,C1.cName,C2.cNum,C2.cName,C3.cNum,C3.cName);
^
classPrivate.cpp:112:63: error: ‘class Student’ has no member named ‘cNum’
StudentProfile p1(num,ID,Fn,Ln,A,G,SN,C1.cNum,C1.cName,C2.cNum,C2.cName,C3.cNum,C3.cName);
^
classPrivate.cpp:112:71: error: ‘class Student’ has no member named ‘cName’
StudentProfile p1(num,ID,Fn,Ln,A,G,SN,C1.cNum,C1.cName,C2.cNum,C2.cName,C3.cNum,C3.cName);
^
classPrivate.cpp:112:80: error: ‘class Student’ has no member named ‘cNum’
StudentProfile p1(num,ID,Fn,Ln,A,G,SN,C1.cNum,C1.cName,C2.cNum,C2.cName,C3.cNum,C3.cName);
^
classPrivate.cpp:112:88: error: ‘class Student’ has no member named ‘cName’
StudentProfile p1(num,ID,Fn,Ln,A,G,SN,C1.cNum,C1.cName,C2.cNum,C2.cName,C3.cNum,C3.cName);
^
well, as the error said, the class Student has no member named cName, that aside in the constructor for Course
1 2 3 4 5
Course::Course( long cNum, long cName )
{
cNum = CourseNum;
cName = CourseName;
}
is not doing what you think it is doing, the assignment is backward, also, you can format your code using the "code"...//your code"/code" tag ( replace "" with [] )