P
Puppet_Sock
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 <iostream>
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);
}
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?
Socks
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 <iostream>
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);
}
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?
Socks