|
-
December 5th, 2004, 10:11 PM
#1
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
-
December 6th, 2004, 01:04 AM
#2
Re: can a class be the store container of the another class
loadIntoTheList() is a prototype of a copy constructor.
Kuphryn
-
December 6th, 2004, 03:35 AM
#3
Re: can a class be the store container of the another class
 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...
-
December 6th, 2004, 04:49 AM
#4
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!
-
December 6th, 2004, 11:35 AM
#5
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
-
December 6th, 2004, 07:55 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|