CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Plain old datatype

    May i know what is Plain old datatype? What is the difference between pod
    and aggregation? What is aggregation?


  2. #2
    Join Date
    Feb 2001
    Location
    Sydney, Australia
    Posts
    1,909

    Re: Plain old datatype

    It's just a very different things ...

    FROM MSDN:
    =============
    Aggregation
    A composition technique for implementing COM objects. It allows you to build a new object by reusing one or more existing objects' interface implementations. The aggregate object chooses which interfaces to expose to clients, and the interfaces are exposed as if they were implemented by the aggregate object. Clients of the aggregate object communicate only with the aggregate object. See also Aggregate object. Contrast with Containment.
    =============
    of course aggregation can be applied not to COM objects - it can be applied to C++ objects too..

    Plain Old Data (POD)- it's the C-styled structs without methods ... just pure data of basic types ...



    Please - rate answer if it helped you
    It gives me inspiration when I see myself in the top list =)

    Best regards,

    -----------
    Igor Soukhov (Brainbench/Tekmetrics ID:50759)
    [email protected] | ICQ:57404554 | http://soukhov.com

    Member of Russian Software Developer Network http://rsdn.ru
    Best regards,
    Igor Sukhov

    www.sukhov.net

  3. #3
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470

    Re: Plain old datatype

    Aggregation is also another term for "implemented in terms of". That is, one class presents a particular interface, but it uses another class to do the actual work. For example, the "Pimpl" idiom:

    // MyClass.h
    class MyClassImpl;
    class MyClass
    {
    public:
    int Method1();
    // Public methods, etc.
    private:
    MyClassImpl* pimpl;
    };

    // MyClass.cpp
    #include "MyClassImpl.h"
    MyClass::MyClass : pimpl(new MyClassImpl)
    {
    }
    int MyClass::Method1()
    {
    return pimpl->Method1();
    }



    Here, MyClassImpl (the aggregated class) does all the work - the methods in MyClass use it. This idiom allows you to hide all of the internal working of a class from the user of that class.

    Another example might be if you want to use, say, MFC's CListCtrl, but don't want to use its methods (maybe you might want to port to a different system some day. In this case, you would write a class that presents a list control interface, then aggregate a CListCtrl and delegate the actual working to it. Later on, you replace the CListCtrl with something else, but your wrapper class's interface doesn't change.

    He who breaks a thing to find out what it is, has left the path of wisdom - Gandalf
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured