hi all
i have 2 classes , 1 of them use the other as below
the student class which use course class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef _STUDENT_H_
#define _STUDENT_H_
#include <iostream>
#include <string>
#include "Course.h"
using namespace std;
class Student
{
int id;
string name;
string matrixNo;
Course* course;
public:
Student();
Student(int, string, string);
void registerCourse(Course&);
};
#endif
course class below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef _COURSE_H_
#define _COURSE_H_
#include <iostream>
#include <string>
using namespace std;
class Course
{
int id;
string name;
string code;
public:
Course();
Course(int, string, string);
};
#endif
can u help me , i wanna know how to access the course which is used in student class ?
example i wanna print the course which registered by student .
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include "Course.h"
#include "Student.h"
using namespace std;
int main()
{
Student student1(1,"Ahmad","BIT1234");
Course course1(1,"Bachelor in IT","BIT");
student1.registerCourse(course1);
cout<<student1.id<<"\n"<<student1.name<<"\n"<<student1.matrixNo<<"\n"<<student1.course<<"\n";/////my problem here
system("PAUSE");
}
it print the address of course , not the value

