Topic: is method overloaded?


Author: Nickolay Mladenov <nikiml@sitius.com>
Date: 2000/01/06
Raw View
Is there a portable way to implement Base:

class Base{
public:
   virtual void method(){}
   bool isMethodOverloaded() const;
};

so if:

class Derived1: public Base{};
class Derived2: public Base{
public:
 void method(){}
};

the program:

int main(){
 assert(Derived1().isMethodOverloaded() == false);
 assert(Derived2().isMethodOverloaded() == true);
 return 0;
}

runs fine ?

nick
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Ron Natalie <ron@sensor.com>
Date: 2000/01/06
Raw View


Nickolay Mladenov wrote:
>

> int main(){
>         assert(Derived1().isMethodOverloaded() == false);

>         assert(Derived2().isMethodOverloaded() == true);
This can be acomplished at compile time by setting method to be
pure virtual.

I guess at run time you can always check if &Derived::method == &Base::method
or not.  But you can't do this from the base class.



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]