Functions having same name return different type values in subclasses.

S

syang8

I want to declare a function F() in a class, which has two children A
and B. I need A.func() return int and B.func() return double. How can
I do that? The F() in parent can be empty or virtual, I just need the
declaration. No implementation is required.
 
B

benben

syang8 said:
I want to declare a function F() in a class, which has two children A
and B. I need A.func() return int and B.func() return double. How can
I do that? The F() in parent can be empty or virtual, I just need the
declaration. No implementation is required.

Don't declare it in the base class.

Ben
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top