Help please!!!

#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;

public:
StudentProfile();
StudentProfile(Person PI,Student SI);
};
class StudentCollection
{
private:
vector<StudentProfile>people;
public:
void getPeople();
void printPeople();
};
Course::Course()
{
CourseNum=0000;
CourseName="Unknowed";
}
Course::Course(long cNum,string cName)
{
cNum=CourseNum;
cName=CourseName;
}
Student::Student()
{
StNo=0;
}
Student::Student(long SN,Course C1,Course C2,Course C3)
{
SN=StNo;
Course1=C1;
Course2=C2;
Course3=C3;
}
Person::Person()
{
SSN=0;
Fname="UnKnown";
Lname="UnKnown";
Age=-1;
Gender='N';
}
Person::Person(long ID,string Fn,string Ln,long A,char G)
{
ID=SSN;
Fn=Fname;
Ln=Lname;
A=Age;
G=Gender;
}
void StudentCollection::getPeople()
{
long num,ID,A,SN,cNum;
string Fn,Ln,cName;
char G;
Student C1,C2,C3;
ifstream fin;
fin.open("data3.txt");
while(fin>>num>>ID>>Fn>>Ln>>A>>G>>SN>>C1.cNum>>C1.cName>>C2.cNum>>C2.cName>>C3.cNum>>C3.cName)
{
StudentProfile p1(num,ID,Fn,Ln,A,G,SN,C1.cNum,C1.cName,C2.cNum,C2.cName,C3.cNum,C3.cName);
people.push_back(p1);
}
fin.close();
}
Last edited on
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!
The error message is here:

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 [] )
Last edited on
Topic archived. No new replies allowed.