CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2004
    Posts
    340

    can a class be the store container of the another class

    i have met such a code:
    Code:
    #include<iostream>
    #include<list>
     class intEntry
    {public:
         intEntry(int a,int b);
         int add();
         
     private:
         int addition1;
         int addition2;
       
    };
    
    intEntry::intEntry(int a,int b)
    {
         addition1=a;
         addition2=b;
    }
      
    int intEntry::add()
    {
        return a+b;
    }
    
    list<intEntry> &   loadIntoTheList(list<intEntry>&p)
    {
        for(int i=0;i<10;i++)
        p.insert(intEntry(i,i+1)) ;  
    }
    i am wondering the exact use of the "list<intEntry>" and also
    i get something similar in the hash containers
    see the function object
    Code:
     
    class functionObject
    {
       returnType operator()(argement)
    {....return returnValue;}
    }
    since it is the first time that i use it in my practice ,i cannot be sure about the full use of this kind of the use ,though i have got to know that if it is used i this way it means that it belongs to two kinds of use one it to use as a datatype ,another is to finish the function as it intends to .i want your opinoin,ok? much appreciation !
    Regards
    jolley

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757

    Re: can a class be the store container of the another class

    loadIntoTheList() is a prototype of a copy constructor.

    Kuphryn

  3. #3
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: can a class be the store container of the another class

    Quote Originally Posted by kuphryn
    loadIntoTheList() is a prototype of a copy constructor.
    Nonsense....'loadIntoTheList' is not a class...at least I cannot see one or read one...

  4. #4
    Join Date
    Nov 2004
    Posts
    92

    Re: can a class be the store container of the another class

    my friend, you can find something helpful in this issue from the chapter 12 of "Thinking in c++" by 2nd Edition By Bruce Eckel, you will find exactly how a container works. Best regards!

  5. #5
    Join Date
    Feb 2002
    Posts
    5,757

    Re: can a class be the store container of the another class

    Well not everything you see is real, and not everything you read is true.

    Kuphryn

  6. #6
    Join Date
    May 2004
    Posts
    340

    Re: can a class be the store container of the another class

    I donot think loadIntoTheList is a copy ctor for it is not in a class ,though it use the object list<intEntry>&p as a parameter , but it just a common function to initialize the list , thanks a lot anyway ,i become clear .

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