Original Post
class A{ public: int foo(){return 0;} }; class B:public A{ public: std::string foo(){return "hi";} }; Is there something wrong with this code? I mean, it compiles, but is it 'imoral' to have in a child class a method that return a different type that the same named method in the parent class? Would java allow it? (i dont feel like installing java just to try this, sorry). Do you know some OOP languages that wouldnt allow such construct? thanks.