관련 머리글 및 선언/정의 된 함수가있는 여러 소스 파일을 만들었습니다. 클래스에 멤버가 없다는 오류가 계속 발생합니다. 나는 회원을 내 개인 회원과 명확하게 연결시키는 세트 기능을 요구하고있다. 내가 포함시켜야 할 다른 것이 있습니까?''명명 된 클래스가 없습니다 ''
#ifndef STUDENTCOLLECTION_CPP
#define STUDENTCOLLECTION_CPP
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
#include "StudentCollection.h"
#include "StudentProfile.h"
#include "Student.h"
#include "Person.h"
#include "Course.h"
void StudentCollection::GetInfo()
{
long SN;
string first;
string last;
string a;
char sex;
long ID;
Course Class1;
Course Class2;
Course Class3;
long num;
string name;
Person PInfo;
Student SInfo;
ifstream fin;
fin.open("info.txt");
fin >> first >> last >> SN >> a >> sex >> ID >> SInfo.Class1.num >> SInfo.Class1.name >> SInfo.Class2.num >> SInfo.Class2.name >> SInfo.Class3.num >> SInfo.Class3.\
name;
while (!fin.eof())
{
StudentProfile New_Stu;
New_Stu.SetAStudentProfile(PInfo, SInfo);
New_Stu.PInfo.SetSetAPerson(SN, first, last, a, sex);
New_Stu.SInfo.SetAStudent(ID, Class1, Class2, Class3);
New_Stu.SInfo.SetACourse(num, name);
StCollection.push_back(New_Stu);
fin >> first >> last >> SN >> a >> sex >> ID >> SInfo.Class1.num >> SInfo.Class1.name >> SInfo.Class2.num >> SInfo.Class2.name >> SInfo.Class3.num >> SInfo.Class3.\
name;
}
fin.close();
}
void StudentCollection::PrintCollection()
{
}
#endif
StudentProfile.h 파일 :
#ifndef STUDENTPROFILE_H
#define STUDENTPROFILE_H
using namespace std;
#include "Person.h"
#include "Student.h"
class StudentProfile
{
private:
Person PersonalInfo;
Student StdInfo;
public:
void SetAStudentProfile(Person PInfo, Student SInfo);
void PrintAStudentProfile();
StudentProfile(){};
StudentProfile(Person PInfo, Student SInfo){};
};
#endif
StudentProfile.cpp :
#ifndef STUDENTPROFILE_CPP
#define STUDENTPROFILE_CPP
#include<iostream>
using namespace std;
#include "StudentProfile.h"
void StudentProfile::SetAStudentProfile(Person PInfo, Student SInfo)
{
PersonalInfo = PInfo;
StdInfo = SInfo;
}
void StudentProfile::PrintAStudentProfile()
{
}
#endif
이 내 편집 오류 (I
#ifndef STUDENTCOLLECTION_H
#define STUDENTCOLLECTION_H
#include<string>
#include<vector>
#include<iostream>
#include<fstream>
using namespace std;
#include "StudentProfile.h"
#include "Person.h"
#include "Student.h"
#include "Course.h"
class StudentCollection
{
private:
vector<StudentProfile> StCollection;
public:
void GetInfo();
void PrintCollection();
StudentCollection(){};
StudentCollection(vector<StudentProfile> StCollection){};
};
#endif
이 .CPP 파일입니다 다른 곳에서 물건과 관련된 문제가 있지만 반드시 원인이) 동일 다음 StudentProfile
클래스의 일부로 정의 어느 것도 New_Stu.PInfo
및 New_Stu.SInfo
, 액세스를 시도
New_Stu.PInfo.SetSetAPerson(SN, first, last, a, sex);
New_Stu.SInfo.SetAStudent(ID, Class1, Class2, Class3);
New_Stu.SInfo.SetACourse(num, name);
:
StudentCollection.cpp:43: error: ‘class StudentProfile’ has no member named ‘PInfo’
StudentCollection.cpp:44: error: ‘class StudentProfile’ has no member named ‘SInfo’
StudentCollection.cpp:45: error: ‘class StudentProfile’ has no member named ‘SInfo’
StudentProfile 클래스의 함수를 사용하여 개인 멤버를 다른 것으로 설정합니다. 나는 그 클래스의 외부 멤버로부터 직접 클래스에 액세스 할 수 없어야한다. 그래서 제 설정 기능에서는 클래스 외부에서 액세스 할 수있는 다른 이름과 동일하게 설정했습니다. – Kevin
@CarNorum - 예, 해당 지역 변수를 사용하려고합니다. – Kevin