www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - abstract problem

reply Regan Heath <regan netwin.co.nz> writes:
--[test.d]--
class A {
public:
	void bar() {
		foo();
	}
private:
	abstract void foo();
}

class B : A {
private:
	void foo() {
	}
}

void main() {
	B b;
}


D:\D\src\build\temp>dmd test.d
d:\D\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

test.obj(test)
  Error 42: Symbol Undefined _D4test1A3fooFZv
--- errorlevel 1

This is supposed to delcare an abstract class A which B is derived from 
filling in the missing functions. What am I doing wrong?

Regan.

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/


-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 23 2004
parent reply Arcane Jill <Arcane_member pathlink.com> writes:
In article <opr922soyy5a2sq9 digitalmars.com>, Regan Heath says...

 What am I doing wrong?
This (I think)...
private:
	abstract void foo();
"private" means CANNOT be inherited. "abstract" means MUST be inherited. The two don't go together. Try changing "private" to "protected". Arcane Jill
Jun 24 2004
next sibling parent Sean Kelly <sean f4.ca> writes:
In article <cbdul8$402$1 digitaldaemon.com>, Arcane Jill says...
In article <opr922soyy5a2sq9 digitalmars.com>, Regan Heath says...

 What am I doing wrong?
This (I think)...
private:
	abstract void foo();
"private" means CANNOT be inherited. "abstract" means MUST be inherited. The two don't go together. Try changing "private" to "protected".
Really? This is a pretty common construct in C++ as a means to separate interface from implementation. I had assumed this was a compiler error. Sean
Jun 24 2004
prev sibling parent reply Regan Heath <regan netwin.co.nz> writes:
On Thu, 24 Jun 2004 07:08:24 +0000 (UTC), Arcane Jill 
<Arcane_member pathlink.com> wrote:

 In article <opr922soyy5a2sq9 digitalmars.com>, Regan Heath says...

 What am I doing wrong?
This (I think)...
 private:
 	abstract void foo();
"private" means CANNOT be inherited. "abstract" means MUST be inherited. The two don't go together. Try changing "private" to "protected".
I'll give it a go, I was trying to say that foo must be inherited as a private method. Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 24 2004
parent Regan Heath <regan netwin.co.nz> writes:
On Fri, 25 Jun 2004 09:25:46 +1200, Regan Heath <regan netwin.co.nz> wrote:

 On Thu, 24 Jun 2004 07:08:24 +0000 (UTC), Arcane Jill 
 <Arcane_member pathlink.com> wrote:

 In article <opr922soyy5a2sq9 digitalmars.com>, Regan Heath says...

 What am I doing wrong?
This (I think)...
 private:
 	abstract void foo();
"private" means CANNOT be inherited. "abstract" means MUST be inherited. The two don't go together. Try changing "private" to "protected".
I'll give it a go, I was trying to say that foo must be inherited as a private method. Regan.
Ok, it works. But.. this is valid C++ class A { public: void bar() { foo(); } protected: private: virtual void foo() = 0; }; class B : A { public: protected: private: void foo() { } }; void main() { B *b = new B(); } and the D I wrote, IMO equivalent to the above, and does not work: --[test.d]-- class A { public: void bar() { foo(); } private: abstract void foo(); } class B : A { private: void foo() { } } void main() { B b; } D:\D\src\build\temp>dmd test.d d:\D\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved test.obj(test) Error 42: Symbol Undefined _D4test1A3fooFZv --- errorlevel 1 So I think this is a bug. Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 25 2004