Covariance

D

Dave

Hello all,

I had thought that both return types and parameter types of virutal
functions could be covariant. However, looking in the Standard (electronic
search), I find reference to only return types being allowed to be covariant
(10.3/5). Also, I thought I remembered the notion of contravariance
existing as well, but I don't find that either. Can anybody point me to the
relevant sections that address these issues?

Thanks!
Dave
 
P

Phlip

Dave said:
I had thought that both return types and parameter types of virutal
functions could be covariant. However, looking in the Standard (electronic
search), I find reference to only return types being allowed to be covariant
(10.3/5). Also, I thought I remembered the notion of contravariance
existing as well, but I don't find that either. Can anybody point me to the
relevant sections that address these issues?

A method's "signature" everything from its name to the right.

Signatures bind at compile time, before virtual method lookup at runtime.

So only virtual method lookup can covariate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top