simple question regarding constructors

Pages: 12
@Disch
Not really. In your example, 'f' is not pure virtual in B


Function A::f is a pure virtual function and it is called from the constructor.
Last edited on
fine fine. Technically I guess you're right but that's not what I meant and you know it.
@Disch


Well. consider the following example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

struct A
{
	A() { f(); }
	virtual void f() const = 0;
	virtual ~A() {}
};

void A::f() const { std::cout << "I'm a pure virtual function.\n"; }

struct B : A
{
	void f() const {}
};


int main()
{
	B();
}
ok ok =)
Topic archived. No new replies allowed.
Pages: 12