#include<iostream>
#include<string>
#include<vector>
usingnamespace std;
class subject
{
string code;
public:
void create_code();
void list_of_code();
};
class student
{
string name;
public:
void create_student();
void list_student();
};
int main()
{
int size_of_student,size_of_subject;
student student_attributes;
subject subject_attributes;
// creating new student first
vector<student>new_student;
cout <<"How many student do you want to create? ";
cin >> size_of_student;
for (int i = 0 ; i < size_of_student; i++)
{
student_attributes.create_student();
new_student.push_back(student_attributes);
// creating subjects
vector<subject>new_subject;
cout <<"How many subject do you want to create? ";
cin >> size_of_subject;
for (int i = 0 ; i < size_of_subject; i++)
{
subject_attributes.create_code();
new_subject.push_back(subject_attributes);
}
cout <<"You successfully created a student with "<<size_of_subject<<" subjects "<<endl;
}
return 0;
}
please notice that my code doesn't include the member function for the classes(late i'll include it but for now help for my questions)
now my questions is, is my way correct to get the student name and new subject by using vector?
another question, how to list all the student? or list all the subject? (cout of vector))
another question is how to liast all student for a specfic subject? can you please show me
I just want to clarify why you need int size_of_subject inside the function create_student.
Hm have you tried just using getline instead of cin inside the main code?? why don't you try to make the vectors a public member and not private it might be a possible reason as to why they can't get the input right. I'll try to look into this further