dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #07736
Re: question concerning Generic* operator=
2008/4/29 <kent-and@xxxxxxxxx>:
>> On Tue, Apr 29, 2008 at 06:46:05PM +0200, Kent-Andre Mardal wrote:
>>>
>>> We have the following operator= in GenericVector
>>>
>>> /// Assignment operator
>>> virtual const GenericVector& operator= (const GenericVector& x) = 0;
>>>
>>> and a similar one in eg. EpetraVector:
>>>
>>> /// Assignment operator
>>> const EpetraVector& operator= (const EpetraVector& x);
>>>
>>> Is this operator an implementation of the operator in GenericVector ?
>>>
>>> Kent
>>
>> I don't think so. We have the same thing in all the concrete classes:
>> first
>>
>> virtual const FooVector& operator= (const GenericVector& x) = 0;
>>
>> and then also
>>
>> const FooVector& operator= (const FooVector& x) = 0;
>>
>> I don't know why we have both. I thought you added this?
>>
>> --
>> Anders
>
> I guess I`m to blame. I added it because otherwise I got into trouble.
> Anyway, I just added
>
> GenericVector& operator=(real a) in GenericVector and
> EpetraVector& operator=(real a) in EpetraVector,
>
> and this seems inconsistent with the other operator=.
> But seems to work fine. I am just confused about operators.
Actually, "operatorFOO" is just the name of a function like any other
function. Overloading and overriding should work the same way.
The differences are mostly in when they're called.
When in doubt, I write a small test and see what happens,
I have lots of such small tests lying around in my sandbox.
--
Martin
References