Puppet_Sock wrote:
> So I've had to take over a project that used an old compiler.
> May not be able to step up to a newer compiler because the
> project uses a library that has equivalent of the following in it.
>
> #include
> class A
> {
> public:
> A();
> virtual void tryit(long val) = 0;
> };
>
> class B: public A
> {
> public:
> virtual void tryit(long val);
> long m_val;
> };
>
> A::A()
> {
> tryit(17);
This is a call to a pure virtual function. The behaviour is U.
> }
>
> void B::tryit(long val)
> {
> m_val = val;
> }
>
> int main()
> {
> B myB;
> std::cout << myB.m_val << std::endl;
> }
>
> I don't think this should work in a compliant compiler. When class A
> tries to find tryit, it should not. I get a linker error in my more
> recent
> compiler.
>
> But the old compiler I'm using for the project happily compiles and
> links, and behaves as though the class A is finding the entry in
> class B for the function tryit.
>
> Am I missing something? This shouldn't work should it?
It should not.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask