hope someone give me some example ....teach me how to do ...

You are asked to create two classes:
a)Class Course with attributes course code and faculty code
b)Class student with attributes studentID, name and an object of course class
c)Write a member function for class student that will access and display a student’s ID and name and his/her course code and faculty code.
d)Then create a main function that will instantiate the class student and send the message to display student’s id and name and his/her course and faculty.
Did you manage to do something?
actually i not understand about that ..so i need some example of that information i send to you all what the information need ..it want to do 2 class ?
it want to do 2 class ?

It says: You are asked to create two classes

If you don't know how to do it, read the tutorials: http://www.cplusplus.com/doc/tutorial/classes/
This is the code i type but error many ...is that example got little bit like that

#include <iostream>
#include<string>
#include<vector>
using namespace std;

class course
{
Public:
course:course(string coursename)
}
name = coursename;
{
string course :getname()
}
return name;
{
void course :addstudent(string student)
}
v.push.back(student);
{
vector(string)course:: getstudent
}
return 0 ;
{
int course::getNumberOfStudent()
}
return v.site;
{
private:
string name;
vector<string>v;
};
int main()
{
vector<string>student;
course course2("data structures");
course course2("database system");
course1.add student("LLL");
course1.add student("ppp");
course1.add student("kkk");
course2.add student("jjj");
course2.add student("hhh");
cout << "the number of student in course1 is << course 1.getNumberOfStudent()<<end1;
for(i = 0;i<course1.getNumberOfStudent();i++)
{
cout << student[i]<<","<<end1;
}
cout << "the number of student in course2 is << course 2.getNumberOfStudent()<<end1;
for(1=0;i < course.getNumberOfStudent;i++)
{
cout << student[i]<<",";
cout<<end1;
}
cout<<"the number of the course is "<< course1.getname()<<end1;
cout<<"the number of the course is "<<course2.getname()<<end1;
return 0;
}

Please use [code][/code] tags and post the error messages.
This part is totally messy:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class course
{
Public: // should be lowercase ( public: )
course:course(string coursename) // remove course: -everywhere-
} // reversed, as most of the braces
name = coursename;
{ 
string course :getname()
}
return name;
{
void course :addstudent(string student)
}
v.push.back(student);
{
vector(string)course:: getstudent // ??? ...
}
return 0 ;
{
int course::getNumberOfStudent()
}
return v.site;
{
private:
string name;
vector<string>v;
};


course1.add student("LLL"); Remove the space between 'add' and 'student'


for(1=0;You mean int i = 0?
i < course.getNumberOfStudent; You need an object and the function paretheses
Also it is a good idea to write the least amount of code then compile, with the exception of really well know and simple things.
#include <iostream>
#include<string>
#include<vector>
using namespace std;

class course
{
public:
course (string course name)

name = coursename;
}
string course:getname()
{
return name;
}
void course :addstudent(string student)
{
v.push.back(student);
}
vector(string)course:: getstudent
{
return 0 ;
}
int course::getNumberOfStudent()
{
return v.site;
}
private:
string name;
vector<string>v;
};
int main()
{
vector<string>student;
course course2("data structures");
course course2("database system");
course1.addstudent("LLL");
course1.addstudent("ppp");
course1.addstudent("kkk");
course2.addstudent("jjj");
course2.addstudent("hhh");
cout << "the number of student in course1 is << course 1.getNumberOfStudent()<<end1;
for(i = 0;i<course1.getNumberOfStudent();i++)
{
cout << student[i]<<","<<end1;
}
cout << "the number of student in course2 is << course 2.getNumberOfStudent()<<end1;
for(i=0;i < course.getNumberOfStudent;i++)
{
cout << student[i]<<",";
cout<<end1;
}
cout<<"the number of the course is "<< course1.getname()<<end1;
cout<<"the number of the course is "<<course2.getname()<<end1;
return 0;
}

still got 4 error can someone help me correct it
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include<string>
#include<vector>
using namespace std;

class course
{
public:
course (string course name)

name = coursename;
}
string course:getname()
{
return name;
}
void course :addstudent(string student)
{
v.push.back(student);
}
vector(string)course:: getstudent
{
return 0 ;
}
int course::getNumberOfStudent()
{
return v.site;
}
private:
string name;
vector<string>v;
};
int main()
{
vector<string>student;
course course2("data structures");
course course2("database system");
course1.addstudent("LLL");
course1.addstudent("ppp");
course1.addstudent("kkk");
course2.addstudent("jjj");
course2.addstudent("hhh");
cout << "the number of student in course1 is << course 1.getNumberOfStudent()<<end1;
for(i = 0;i<course1.getNumberOfStudent();i++)
{
cout << student[i]<<","<<end1;
}
cout << "the number of student in course2 is << course 2.getNumberOfStudent()<<end1;
for(i=0;i < course.getNumberOfStudent;i++)
{
cout << student[i]<<",";
cout<<end1;
}
cout<<"the number of the course is "<< course1.getname()<<end1;
cout<<"the number of the course is "<<course2.getname()<<end1;
return 0;
}


still got 4 error somebody please help me correct it ?
You are missing a brace on line 10,
You still have the course: things to remove,
You are missing a doublequote on line 43,
You are not declaring i in the loops
Topic archived. No new replies allowed.