Nick,
I'm afraid this batch of questions looks too much like homework or
something like that...
Searching the FAQs would provide you the answers.
"nick" <i1********@yahoo.com> wrote in message
news:dl***********@justice.itsc.cuhk.edu.hk...
: ex1.
: foo(Person p);
: foo(const Person p);
When a parameter is passed by value, the 'const' applies to the copy
of the object used within function foo.
Overloading will work as expected if you pass the parameter by
reference:
void foo( Person& p );
void foo( Person const& p );
: ex2.foo(Person *p);
: foo(const Person *p);
Note that the implementation of the first function could be written
as:
void foo( Person * const p ) { /* ... code ... */ };
: ex3.foo(Person p);
: foo(Person p) const;
:
: why the pairs in ex1 are treated as the same function.Invalid
: overloading. but ex2 is ok?
:
: what is the meaning is ex3(foo(Person p)const;)?
I'll leave this answer up to you.
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact
form
Brainbench MVP for C++ <>
http://www.brainbench.com