Re: const ref vs. pointer
- From: "Vladimir Grigoriev" <vlad.moscow@xxxxxxx>
- Date: Thu, 2 Nov 2006 18:30:41 +0300
You shoul get a compiler error for the statement
Employee& GetEmployee() const;
Vladimir Grigoriev
"Luca" <nojunk@xxxxxxxxxx> wrote in message
news:eicbb9$ppv$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have 2 questions:
1. Which one is the best: Returning member variables of the class by const
ref or returning by pointer?
e.g.:
Employee* GetEmployee() const;
Employee& GetEmployee() const;
2. Which one is best: Passing a variable by const ref or by pointer?
e.g.:
void SetSalary(Employee* e);
void SetSalary(const Employee& e);
Thanks
.
- Follow-Ups:
- Re: const ref vs. pointer
- From: Ben Voigt
- Re: const ref vs. pointer
- References:
- const ref vs. pointer
- From: Luca
- const ref vs. pointer
- Prev by Date: Re: warning C4238 : cast reference in void*
- Next by Date: Re: warning C4238 : cast reference in void*
- Previous by thread: Re: const ref vs. pointer
- Next by thread: Re: const ref vs. pointer
- Index(es):
Relevant Pages
|