Adding objects of one class to the data of another class

Viktor Anastasov

I have a class Course with information about a course in the university (like when in starts, how long it is, which day of the week, etc). Now I have to do a class Semester with an undefined length of courses :

class Semester {
    public :
       void addCourse(Course c);
    private :
       Course* courses;
}

So I'd like to know how can I do the addCourse function so that I can add infinite number of courses (class Course) to my class Semester ?

101010

Take a look at the code below:

class Semester {
    public :
       void addCourse(Course *c) { courses.push_back(c); }
    private :
       std::vector<Course*> courses;
};

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Adding objects of one class to the data of another class

From Dev

Adding one or more instance of a class in another class

From Dev

Adding data to TableView in another class

From Dev

Adding data into arrayList of another class

From Dev

Adding objects to ArrayList from another class

From Dev

Adding objects to an ArrayList from another class

From Dev

Adding objects to ArrayList from another class

From Dev

Adding objects to an ArrayList from another class

From Dev

Adding an object of one class to an object of another class and checking for duplicates in Python

From Dev

Python 2.7 : How to use objects of one class in another class?

From Dev

Static Array of objects of one class inside another class/ Constructors

From Dev

One class data use in another class data C#

From Dev

Using objects of a class in another class?

From Dev

How to use data from one class into another?

From Dev

Retrieving data from another class in one query

From Dev

Data Conversion from one class type to another class type

From Dev

Access Data Variable from one class in another class

From Dev

controlling objects in another class

From Dev

In what situations can methods of one class be invoked on objects of another?

From Dev

Java : Is it possible to return an array of Objects from one class to another

From Dev

Adding Class one by one , each class adding after one second

From Dev

Adding Objects to Array in a different class

From Dev

Copy data from one object from one class to another boject in another class in Android

From Dev

Data efficiency of class objects

From Dev

How to pass NSobject class data from one class to another class in ios?

From Dev

Is there a way I can make a class that accepts multiple objects in a list instead of using Children and adding one by one?

From Dev

Add multiple class objects from another class

From Dev

How to pass itcl object of one class to object of another class and use the functions of the passed objects?

From Dev

Java: How can I use objects instantiated in one class in another class?

Related Related

  1. 1

    Adding objects of one class to the data of another class

  2. 2

    Adding one or more instance of a class in another class

  3. 3

    Adding data to TableView in another class

  4. 4

    Adding data into arrayList of another class

  5. 5

    Adding objects to ArrayList from another class

  6. 6

    Adding objects to an ArrayList from another class

  7. 7

    Adding objects to ArrayList from another class

  8. 8

    Adding objects to an ArrayList from another class

  9. 9

    Adding an object of one class to an object of another class and checking for duplicates in Python

  10. 10

    Python 2.7 : How to use objects of one class in another class?

  11. 11

    Static Array of objects of one class inside another class/ Constructors

  12. 12

    One class data use in another class data C#

  13. 13

    Using objects of a class in another class?

  14. 14

    How to use data from one class into another?

  15. 15

    Retrieving data from another class in one query

  16. 16

    Data Conversion from one class type to another class type

  17. 17

    Access Data Variable from one class in another class

  18. 18

    controlling objects in another class

  19. 19

    In what situations can methods of one class be invoked on objects of another?

  20. 20

    Java : Is it possible to return an array of Objects from one class to another

  21. 21

    Adding Class one by one , each class adding after one second

  22. 22

    Adding Objects to Array in a different class

  23. 23

    Copy data from one object from one class to another boject in another class in Android

  24. 24

    Data efficiency of class objects

  25. 25

    How to pass NSobject class data from one class to another class in ios?

  26. 26

    Is there a way I can make a class that accepts multiple objects in a list instead of using Children and adding one by one?

  27. 27

    Add multiple class objects from another class

  28. 28

    How to pass itcl object of one class to object of another class and use the functions of the passed objects?

  29. 29

    Java: How can I use objects instantiated in one class in another class?

HotTag

Archive