10.3 — Aggregation

In the previous lesson on Composition, we noted that object composition is the process of creating complex objects from simpler one. We also talked about one type of object composition, called composition. In a composition relationship, the whole object is responsible for the existence of the part.

In this lesson, we’ll take a look at the other subtype of object composition, called aggregation.


To qualify as an aggregation, a whole object and its parts must have the following relationship:

  • The part (member) is part of the object (class)
  • The part (member) can belong to more than one object (class) at a time
  • The part (member) does not have its existence managed by the object (class)
  • The part (member) does not know about the existence of the object (class)

Like a composition, an aggregation is still a part-whole relationship, where the parts are contained within the whole, and it is a unidirectional relationship. However, unlike a composition, parts can belong to more than one object at a time, and the whole object is not responsible for the existence and lifespan of the parts. When an aggregation is created, the aggregation is not responsible for creating the parts. When an aggregation is destroyed, the aggregation is not responsible for destroying the parts.

For example, consider the relationship between a person and their home address. In this example, for simplicity, we’ll say every person has an address. However, that address can belong to more than one person at a time: for example, to both you and your roommate or significant other. However, that address isn’t managed by the person -- the address probably existed before the person got there, and will exist after the person is gone. Additionally, a person knows what address they live at, but the addresses don’t know what people live there. Therefore, this is an aggregate relationship.

Alternatively, consider a car and an engine. A car engine is part of the car. And although the engine belongs to the car, it can belong to other things as well, like the person who owns the car. The car is not responsible for the creation or destruction of the engine. And while the car knows it has an engine (it has to in order to get anywhere) the engine doesn’t know it’s part of the car.

When it comes to modeling physical objects, the use of the term “destroyed” can be a little dicey. One might argue, “If a meteor fell out of the sky and crushed the car, wouldn’t the car parts all be destroyed too?” Yes, of course. But that’s the fault of the meteor. The important point is that the car is not responsible for destruction of its parts (but an external force might be).

We can say that aggregation models “has-a” relationships (a department has teachers, the car has an engine).

Similar to a composition, the parts of an aggregation can be singular or multiplicative.

Implementing aggregations

Because aggregations are similar to compositions in that they are both part-whole relationships, they are implemented almost identically, and the difference between them is mostly semantic. In a composition, we typically add our parts to the composition using normal member variables (or pointers where the allocation and deallocation process is handled by the composition class).

In an aggregation, we also add parts as member variables. However, these member variables are typically either references or pointers that are used to point at objects that have been created outside the scope of the class. Consequently, an aggregation usually either takes the objects it is going to point to as constructor parameters, or it begins empty and the subobjects are added later via access functions or operators.

Because these parts exist outside of the scope of the class, when the class is destroyed, the pointer or reference member variable will be destroyed (but not deleted). Consequently, the parts themselves will still exist.

Let’s take a look at a Teacher and Department example in more detail. In this example, we’re going to make a couple of simplifications: First, the department will only hold one teacher. Second, the teacher will be unaware of what department they’re part of.

In this case, teacher is created independently of dept, and then passed into dept’s constructor. When dept is destroyed, the m_teacher pointer is destroyed, but the teacher itself is not deleted, so it still exists until it is independently destroyed later in main().

Pick the right relationship for what you’re modeling

Although it might seem a little silly in the above example that the Teacher’s don’t know what Department they’re working for, that may be totally fine in the context of a given program. When you’re determining what kind of relationship to implement, implement the simplest relationship that meets your needs, not the one that seems like it would fit best in a real-life context.

For example, if you’re writing a body shop simulator, you may want to implement a car and engine as an aggregation, so the engine can be removed and put on a shelf somewhere for later. However, if you’re writing a racing simulation, you may want to implement a car and an engine as a composition, since the engine will never exist outside of the car in that context.

Rule: Implement the simplest relationship type that meets the needs of your program, not what seems right in real-life.

Summarizing composition and aggregation


  • Typically use normal member variables
  • Can use pointer members if the class handles object allocation/deallocation itself
  • Responsible for creation/destruction of parts


  • Typically use pointer or reference members that point to or reference objects that live outside the scope of the aggregate class
  • Not responsible for creating/destroying parts

It is worth noting that the concepts of composition and aggregation are not mutually exclusive, and can be mixed freely within the same class. It is entirely possible to write a class that is responsible for the creation/destruction of some parts but not others. For example, our Department class could have a name and a Teacher. The name would probably be added to the Department by composition, and would be created and destroyed with the Department. On the other hand, the Teacher would be added to the department by aggregation, and created/destroyed independently.

While aggregations can be extremely useful, they are also potentially more dangerous. Because aggregations do not handle deallocation of their parts, that is left up to an external party to do so. If the external party no longer has a pointer or reference to the abandoned parts, or if it simply forgets to do the cleanup (assuming the class will handle that), then memory will be leaked.

For this reason, compositions should be favored over aggregations.

A few warnings/errata

For a variety of historical and contextual reasons, unlike a composition, the definition of an aggregation is not precise -- so you may see other reference material define it differently from the way we do. That’s fine, just be aware.

One final note: In the lesson Structs, we defined aggregate data types (such as structs and classes) as data types that groups multiple variables together. You may also run across the term aggregate class in your C++ journeys, which is defined as a struct or class that has no provided constructors, destructors, or overloaded assignment, has all public members, and does not use inheritance -- essentially a plain-old-data struct. Despite the similarities in naming, aggregates and aggregation are different and should not be confused.

Quiz time

1) Would you be more likely to implement the following as a composition or an aggregation?
1a) A ball that has a color
1b) An employer that is employing multiple people
1c) The departments in a university
1d) Your age
1e) A bag of marbles

Show Solution

2) Update the Teacher/Dept example so the Dept can handle multiple Teachers. The following code should execute:

This should print:

Department: Bob Frank Beth
Bob still exists!
Frank still exists!
Beth still exists!

Hint: Use a std::vector to hold the Teachers, and std::vector::push_back() to add Teachers.

Show Solution

10.4 -- Association
10.2 -- Composition

149 comments to 10.3 — Aggregation

  • masterOfNothing


    Can this be considered somewhat correct:

    Nullpointer caught
    Department: Teacher Teacher2 Teacher3

    Is the vector array in the code holding pointers or copies of Teacher objects?

    I honestly didn't know about this syntax:

    Cannot remember whether this was mentioned in previous lessons (about storing pointers in a vector array).
    I know there was mentioned about storing pointers in c-style arrays, but I'm still conflicted about the correct syntax.

    • If it works, it's somewhat correct.

      - Initialize your variables with brace initializers.
      - Pass/return non-fundamental types by const reference.
      - Line 24: Should be `else`, not `else if`.
      - `Teacher::getName` should be const.
      - Use single quotation marks for characters (' ' instead of " ").
      - Moving the nullptr check into `add` and calling `add` from the constructor is safer.

      > Is the vector array in the code holding pointers or copies of Teacher objects?
      It's storing copies. You can tell by the declaration and use of the vector.

      An `std::vector` can store any type you can store in a C-style array (I'm not sure about references right now).

      • masterOfNothing

        I mean, I though it counts as aggregation if the member (std::vector<Teacher> in this case ) is supposed to store pointers exclusively. So when the original data information is changed (Teacher instances), the class member (Department) pointing to that original data is automatically changed as well. So that's why I'm puzzled whether the example I typed was actually an aggregation.

        Is using single quote marks for single characters better memory-wise?

        >>>"Moving the nullptr check into `add` and calling `add` from the constructor is safer."

        Makes sense.

        Thank you once again for your continuous support. You and the creator of these tutorials, Alex, are the kind of people, that make this world spin around, figuratively speaking.

        • I don't know about aggregation, maybe @Alex can tell you more about that.
          If you want to be able to modify the original and see changes of the original, you need to store pointers.

          > Is using single quote marks for single characters better memory-wise?
          Memory- and performance-wise.
          Double quotation marks always store a 0-terminator. chars don't, because they're always the same length.
          When you pass a string (double quotation marks) to a function, that function has to check the length and loop through the string (Even if it's just 1 character long). It doesn't have to do this with chars, as they're always the same length.

          > Thank you once again for your continuous support.
          You're welcome :)

  • Louis Cloete

    If I omit a constructor for a class, I get this error in my build: 'Department::m_teachers' should be initialized in the member initialization list [-Werror=effc++]. This is after I enabled the stricter compiler error options as suggested in Chapter 0.11. It is a little ridiculous that I should write a constructor initializing each and every member in an initializer list to avoid the warning (and thus error, because of the -Werror flag, thus necessary to get a successful compilation). What can I do? What is a good initializer for a std::vector? I could put it next to the declaration of the member, like this

    but then, what is a legal initializer? What type should it be?

    • That error occurs when you have a constructor and don't initialize a member (But ignore it, or assign to it).
      Initialize all variables at their declaration and you're fine.
      Empty curly brackets initialize to the default value of the declared type.

      • Louis Cloete

        Thanks! I remembered about the empty braces after I posted and got it to work that way, but thanks anyway for the explanation. Now it is publicly available for everyone else to see if they encounter a similar problem =)

  • hassan magaji

    hi Alex/everyone,
    here is my solution for the quiz:

    I have a question though,
    can an object(class) start as aggregation and ends up as composition?
    for example suppose i want to design a racing game where the players assembles  cars from scratch(aggregation) after which they engage in a race with their cars as a whole(composition).

    thank you the awesome tuts.

  • Jon

    For quiz question #2, is there any downside to using a ranged for-loop  in the << operator overload function?

    • Nope. The for-each loop shorter and easier to read.

    • Louis Cloete

      @Alex, I think the answer should also use a for-each loop. It is harder to have off-by-one errors or forget to update the condition in a for-each, thus I consider it better style in C++11 (or whenever for-each was introduced) and later.

      • Alex

        Agreed, the original answer was written pre-C++11. I've updated it to use for-each.

        Thanks for the ping on this.

        • Louis Cloete

          Yes, one can see the "line" between the pre-C++11 tutorials and the post-C++11 tutorials very clearly ;)

          Same with the random stuff. In a lot of exercises using <random> and the Mersenne twister is better, but you didn't get round to updating it yet.

  • Flo

    Hi, I was wondering if there is a reason not to use references in the class definition of Department instead of pointers, somewhat like this:

    Are there any downsides to this other than that the user can not be sure if add() is called by value oder reference?

  • Gaurav Arya


    My solution to the given problem is shown below. Please comment if it can be improved.
    I tried to ensure that I implement suggestions and comments received in the previous lessons i.e.
    using uniform or direct initialization, passing string by references instead of copy.

    • Hi!

      * Line 11, 19, 47: Although these will initialize themselfs, I recommend initializing them for consistency.
      * Line 29: The return type of @dept.m_dept.size() is std::vector<Teacher *>::size_type. The only information given about this type, is that it's an unsigned integer type. unsigned int isn't guaranteed to be able to store it. Use @std::size_t or @auto. Since you don't need the index, you could also use a for-each-loop.
      * Line 29, 40-42: Uniform initialization

      Your code allows

      because @Teacher::getName returns a non-const reference.
      It doesn't allow calls to @Teacher::getName on a const instance of @Teacher, because @Teacher::getName is not marked const.

      • Gaurav Arya

        Hi nascardriver!

        Thank you so much for your valuable inputs. I have made the necessary changes and this is the gist of it, item by item.

        1) converted to uniform initialization with blank/empty/null value.

          #line 11 changed from


          #line 19 changed from


          #line 47 changed from


        2) At #line 29, modified the return type of



        . I would also like to report that changing from


        also works. Didn't try auto at all as I would have surely missed out on this wonderful piece of information. Also changed the counter variable 'i' from 'i(0)' to 'i{0} to initialize uniformly.

        May I ask which one should we prefer and are there any specific pros/cons to each of them w.r.t each other and vice versa? (This applies to std::vector<Teacher*>::size_type vs size_t)

        3) Yes, line

        does change value of t2 from 'Frank' to 'Peter'. I never imagined that t2 could be manipulated in such a way. Not cool! (for me of course). But how does this happen? how can fetching name via getName() could also be coupled with assignment? I understand the part that if a variable is not const, it could be changed. Why are we able to assign to a 'reference' when it was already initialized?


        • > May I ask which one should we prefer
          @std::size_t always works, because it can store every size, but it might be overkill and thus a waste of memory.
          @std::vector<Teacher*>::size_type is the correct type, but it takes a while to write. If you know what you're doing, you can use @auto to automatically use the correct type. Though, if you're not confident about which type is used where, this could lead to trouble.

          Remember how references are like aliases?

          > Why are we able to assign to a 'reference' when it was already initialized?
          References can and must be initialized exactly once. Every following access is like access to the variable they're referring to.

          doesn't modify the reference, @str still references @t2.m_name. It modifies the referenced variable.

          If you don't like to think of references as aliases, you can also think of them as pointers

          Same thing, just more syntax. But this might make understanding why @Teacher::getName has to return a const easier.

  • Hello Alex,

    if the external party destroyed the part in case of aggregation, is there a way to notify the parent/whole class of a
    destruction of one of the elements ?

    Also Could i ask is this considered as composition ?

    • Alex

      > 1) if the external party destroyed the part in case of aggregation, is there a way to notify the parent/whole class of a destruction of one of the elements?

      Not really. Generally you'd want to ensure that outside party can't destroy elements directly, that they must do so through some interface, and that interface can manually handle notifying the parent classes of the destruction.

      > 2) Could i ask is this considered as composition ?


  • Hi been away a few days but returned to try this.  The simplest approach I could use was this:

    I'm actually busy trying to write the code to produce a TV Testcard and output it to a UHF Radio transmitter using C++ on an Arduino Due. Trying to find libraries in the Arduino world to make the code do what I want is a nightmare...

  • Andi

    Hi! Does the use of static members in a class or global variables make it an aggregation?

    • Alex

      No. Static members belong to the class, not the class objects, and global variables belong to the program, not class objects. Composition, aggregation, and association generally apply to members that are part of class objects.

  • Soldier76


    I would like to ask a simple question.

    Consider the following code:

    Could you please explain to me what is the meaning of initialize the constructor's parameter with nullptr?


    • Hi Soldier!

      Have a look at lesson 7.7

      Lesson 7.7 - Default parameters

    • Gaurav Arya

      The constructor shown below has 2 objectives.

      1. It serves as a default constructor i.e no arguments are provided. When user instantiates object without any arguments, default pointer location will be set to

      2. It serves as a constructor with arguments i.e. a Teacher* teacher is supplied. In that case, the constructor will initialize Department data member m_teacher with the given argument i.e teacher.

  • Quoxa

    although this is a question regarding destructors, I guess it is more relevant to post it here since the example used is from this section.

    My question is: why does the destructor seemed to be called twice in the following program (solution to quiz question 2)?

    The output is:

    Department: Bob Frank Beth
    CS department destroyed
    CS department destroyed
    Bob still exists!
    Frank still exists!
    Beth still exists!

    PS when i used the debugger, the program jumped to the start of this block

    after it exited the block, before it exits the block again.

    If it is relevant, the IDE used was Code::Blocks.

  • DecSco

    In the add() function, why can I not use a const pointer like this:

    And in a similar vein, why can't I use a for-each loop for outputting the names? EDIT: When adding a const keyword to the getName() function, it works.

    • nascardriver

      Hi DecSco!

      > why can I not use a const pointer like this
      Imagine you pass a teacher to @add, you don't expect it to be modified, because @add takes a const Teacher. @m_teachers stores non-const teachers, by pushing @t into @m_teachers you're saying that @t can be modified, which contradicts the declaration of @t.

      > why can't I use a for-each loop [...]
      You can, you just cant make the iterator const, or can't call @getName, because @getName isn't marked as const.

      You can only ever call functions marked as const on an object that is marked as const.

      • DecSco

        I only wanted to declare that the add() function itself doesn't modify the argument. That is not possible?

        • nascardriver

          Yes, that's exactly what you did. But @m_teachers stores teachers that _can_ be modified. @add cannot store an immutable teacher in a vector of mutable teachers.

  • aymen

    Hi Alex,

    It may looks a silly question but what do u mean by

    for the composition
    "Can use pointer values if the composition class automatically handles allocation/deallocation" ? for the Body/Head example what is that composition class ? the Body or the head ?


  • David

    Hi! Why not use a for each loop here:

  • Ritesh

    Hey Alex,
    I have problem solving this

    1) I tried doing this
    ostream& operator<<(ostream &out, const Department &dept)
        out << "Department:";
        for (int i = 0; i < dept.tptr.size(); ++i)//tptr is the name of vector variable
            out << dept.tptr.pop_back()->getName()<<" ";
        return out;
    it gives an error
    'void std::vector<Teacher*,std::allocator<_Ty>>::pop_back(void)':convert 'this' pointer from 'const std::vector<Teacher*,std::allocator<_Ty>>' to 'std::vector<Teacher*,std::allocator<_Ty>>&'
    it states something that object has type qualifiers that are not compatible with member function
    also it gives another error that left of ->getName() must be class/struct/union.

    so if I remove the const part from the department object in the function then it only gives 1 error that is
    left of '->getName()' must be class/struct/union.  
    what is happening when we make department object const in the above code

    2) So I tried to test the above code for back(), dept.tptr.back() even though It makes no sense and  even if I make the department object constant or not, it still magically works. so why wont it work for pop_back() for both the cases const/non const one;

    • nascardriver

      Hi Ritesh!

      @std::vector::pop_back doesn't return anything, see

  • Saumitra Kulkarni

    In the following code :

    We shallow copied the teacher instance in the Department constructor and now m_teacher and teacher are the same piece of memory. Now as the dept instance goes out of scope it is destroyed.

    My doubt here is that what exactly happens to the memory when it goes out of scope, had we added a destructor the code would have undefined behavior since the same address would be deleted twice(when we delete the teacher instance later.) similar case to what we saw in the example in the deep copying part in lesson 9.15.
    So to my understanding going out of scope isn't obviously same as using the delete keyword in destructor Since this code works fine .

    • Alex

      When local variable dept goes out of scope, its members are destroyed.

      When a pointer variable is destroyed, the memory allocated for the pointer variable itself is reclaimed (on the stack), but whatever content was being pointed to still exists.
      When a pointer is deleted, the pointer variable itself still exists, but the content being pointed to is reclaimed (on the heap).

  • Ran

    Could someone explain why Alex preferred declaring the add function
    using a pointer of the Teacher class? What is its strength over the
    following code?

    • nascardriver

      Hi Ran!

      You're relying on the teacher only having a name property, that's bad.
      You're creating a new teacher every time you add a teacher, that's bad.
      If you're taking the teachers back out of the Department you'll either create a copy of the teacher again or have a potential dangling pointer/reference, that's bad.

  • firstboy

    for (auto &ref: dept.m_teacher)
                out << ref.getName() << " ";

    alex can you tell what's the meaning of condition in for loop, auto keyword meaning.

    • nascardriver

      Hi firstboy!

      There's no condition in this loop. It's a for-each-loop (Lesson 6.12a).
      The 'auto' is used to automatically use the data type of the elements in @dept.m_teacher.

  • Serge B

    Hi Alex,

    and this other part of code:

    Why do sometimes we need a "delete[] something" and "delete something" at other times?

    Thank you!

  • Bac Dang

    Hi Alex !
    I have 2 code as below:


    The #1 build have error:
    Error    C4700    uninitialized local variable 'test' used    Test    e:\cpp\learnc\learnc\test\source.cpp    20    

    The #2 run as well.
    Can you explain why ?
    Thank you.

    • Alex

      In case 1, the compiler is able to detect that test has not been initialized. In case 2, the compiler is unable to detect that test hasn't been initialized.

      Both are incorrect, even though the second one runs.

      • Bac Dang

        i'm run with visual studio 2017. That mean, it depend on the compiler.
        Thanks you

        • Alex

          Yes, modern compilers will try to detect when you've done certain things that you should not be doing, like using the value of an uninitialized variable. Sometimes they are able to do a good job of this. Other times, not so much.

  • Rapol

    Hello, I didn't see your hint so i did your second quiz task with pointer of pointers, can I ask you a question: Are there any memory leaks in this code? Thanks :) Your tutorials on C++ are the best I have ever seen!

  • Lim Che Ling

    I have finally made the program work and I found my code has different concept with the answer provided. One point to note here is that I have to make getName() const, or I get the error on line (out << ref.getName() << " ";) saying "function member getName not viable: 'this' argument has type const Teacher' but function is not marked....".
    Any comment?

    Great tutorial! Thanks so much!

    #include <string>
    #include <iostream>
    #include <vector>

    class Teacher
        std::string m_name;
        Teacher(std::string name)
        : m_name(name)
        std::string getName() const { return m_name; }

    class Department
        std::vector<Teacher> m_teacher; // This dept holds only one teacher for simplicity, but it could hold many teachers
        void add(Teacher *teacher){
        friend std::ostream& operator<< (std::ostream &out, const Department &dept) {
            out << "Department: ";
            for (auto &ref: dept.m_teacher)
                out << ref.getName() << " ";
            out << "\n";
            return out;

    int main()
        // Create a teacher outside the scope of the Department
        Teacher *t1 = new Teacher("Bob"); // create a teacher
        Teacher *t2 = new Teacher("Frank");
        Teacher *t3 = new Teacher("Beth");
        {// Create a department and use the constructor parameter to pass the teacher to it.
            Department dept;// create an empty Department
            std::cout << dept;
        } // dept goes out of scope here and is destroyed
        // Teacher still exists here because dept did not delete m_teacher
        std::cout << t1->getName() << " still exists!\n";
        std::cout << t2->getName() << " still exists!\n";
        std::cout << t3->getName() << " still exists!\n";
        delete t1;
        delete t2;
        delete t3;
        return 0;

  • Brad

    In my code I had written an overloaded operator<< for both Teacher and Department because I didn't setup my m_teacher vector with a pointer data type. My solution still worked but when I saw your solution I went on a few hour look at pointers and reducing redundancy in my code. Any day where I learn more about things I thought I understood is a good day! So thank you again for these great tutorials!

  • Dani

    Hello Alex,,,
    i try to understand the last question,it's make me little confuse, i don't know deference between
    " std::vector<Teacher*> m_teacher " and " std::vector<Teacher>*m_teacher; ".
    Can you explain me ?Thnks for the answer

    • Alex

      std::vector m_teacher declares a std::vector containing pointers to Teacher objects. This is a common way to implement an aggregation or association of Teachers.
      *m_teacher declares a pointer to a std::vector containing Teachers. I'm struggling to think of a case where you'd ever do this.

  • Milos

    Hello, you should include iostream in the above example.

  • KnowMore

    Consider The Following Snippet :-

    It Gives Me An Error :-

    Can You Tell Me, Why?
    Also, It works perfectly if I remove the const keyword !
    Thanks in Advance ! Reply ASAP.

    • Alex

      temp is a const Department, but you're trying to call member function getName(), which is non-const. Instead of making temp non-const, you should make member function getName() const.

      • KnowMore

        Oh yes ! So Foolish !
        Sorry for Disturbing !
        Tysm :)

      • Help

        Hi Alex!
        In his code he doesn't have std::vector <Teacher> m_TrackTeachers; in pointer and in urs u got Teacher*. what makes it diffrent is that when he does add he use m_TrackTeachers.push_back(*temp); and u dont have pointer to temp. It's just something i really do have problem understanding, and the only thing that is diffrent is std::vector <Teacher> m_TrackTeachers;
        what is this called that i need to read about to understand this better?


        • Alex

          Basically, you use a non-pointer when you want the array to own (manage the existence of) the object. You use a pointer when you want the array to hold the object, but not manage it.

          • Help

            Hi Alex!
            I got one question and wounder. when u create a std::vector<Something> m_something; and when u do m_something.push_back u actually make a copy of the object and push it back? while u do std::vector<*Something> m_something; and just m_something.push_back u actually push back the pointing to that object so u dont make copy? thats why he is making a push_back(*temp) and u dont cause u already pointing to that object? He needs to point to object he wanna push back so it doesnt make a copy while u already pointing? I am correct?

            Thanks in advance!:)

            • Alex

              > when u create a std::vector m_something; and when u do m_something.push_back u actually make a copy of the object and push it back?

              Yes. And this can cause object slicing if you're not careful.

              > while u do std::vector< *Something> m_something; and just m_something.push_back u actually push back the pointing to that object so u dont make copy?

              Yes, in that case we're just pushing the pointer value itself.

              If you want to point at something that already exists elsewhere, you'll want to use a pointer so you can point at the object (wherever it lives) rather than making a copy.

  • Omri

    In the following:
    "You may also run across the term “aggregate class” in your C++ journeys, which is defined as a struct or class that has only default constructors/destructors, no protected or private members, and no inheritance or virtual functions."
    A. Did we discuss the concepts of "protected member" "inheritance" or "virtual functions"?
    I understand this as follows:
    "You may also run across the term “aggregate class” in your C++ journeys, which is defined as a struct or class that has only *a* default *constructor/destructor* and public members  *(no other features such as: private members, overloaded constructors/destructors and, to be discussed,  protected members, inheritance or virtual functions)*."
    Is this correct?

    • Alex

      1) We haven't covered protected members or inheritance yet -- that's covered next chapter. I've updated the wording to speak more towards stuff we have covered.
      2) I also updated the text here a bit -- to be an aggregate class, you can't define any constructors or destructors (not even a default constructor).

  • Omri

    "In the lesson Structs, we defined *an* aggregate data types (such as structs and classes) as *a* data types that *groups* multiple variables together."
    "In the lesson Structs, we defined ** aggregate data types (such as structs and classes) as ** data types that *group* multiple variables together."

  • Omri

    "Typically use pointer or reference members that point to or reference objects that *lives* outside the scope of the aggregate class."
    "Typically use pointer or reference members that point to or reference objects that *live* outside the scope of the aggregate class."

  • hi alex
    mujy tu opp ki samjh nhi ati koi hal tu bta yara
    i cannot understand opp tell me solution

Leave a Comment

Put all code inside code tags: [code]your code here[/code]