Thread overview
abstract problem
Jun 24, 2004
Regan Heath
Jun 24, 2004
Arcane Jill
Jun 24, 2004
Sean Kelly
Jun 24, 2004
Regan Heath
Jun 25, 2004
Regan Heath
June 24, 2004
--[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/
June 24, 2004
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



June 24, 2004
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


June 24, 2004
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/
June 25, 2004
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/