#include <iostream>
#include<vector>
using namespace std;
struct Course
{
int ID;
string name;
};
struct Student
{
int numb;
int ID;
string name;
vector<Course>courses;
};
void get_info(Student& the_info);
void print_info(Student& the_info);
int main()
{
vector<Course>courses;
courses.push_back(Course());
Student std;
get_info(std);
print_info(std);
return 0;
}
void get_info(Student& the_info)
{
cout << "Number of courses: ";
cin >> the_info.numb;
cout << "Enter Student ID: ";
cin >> the_info.ID;
cout << "Enter Student Name: ";
cin >> the_info.name;
}
void print_info(Student& the_info)
{
}
Write a C++ program that declares a struct called course with the following attributes:
int ID;
string name;
Then create a struct called student that contains the following attributes:
int ID;
string name;
Vector of courses
Write a main program that:
1. Declare structure student
2. Pass it to a function by reference to fill it in with information
3. Pass it to a function to print it out
While filling the student structure, ask the user for the number of courses and fill in the vector accordingly.
1 answer