🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: de.comp.lang.c++
Article #22

Schwierige Erbschaft

#22
From: Martin Kneissl
Date: Sun, 09 Aug 1992 19:37
58 lines
1631 bytes
Hallo!

Warum ist das folgende Programm falsch?
Wer kann mir helfen?

(Der work-around ist klar, ich muss mit Pointern auf die
Basisklasse arbeiten, aber warum geht es nicht so wie es ist?)

////////////////// SCHNIPP ////////////////// SCHNAPP ////////////////////

// Compiler: TurboC++ v 1.01 ( habe nichts anderes :-< )

class Point {
		int x,y;
	public:
		Point(int _x,int _y) : x(_x), y(_y) {}
	};

class Base  {
	public:
		virtual void func(Point ) =0; 		 
		virtual void func(int x, int y) {
			func(Point(x,y)); 
			}
		};

class Derived : public Base {
	public:
		void func(Point) {}
	};

Derived 	vDerived;
Derived * 	pDerived=&vDerived;
Base * 		pBase=&vDerived;

int main() {
	pBase->func(3,4); 		
		// ok
	pDerived->func(3,4);	
		// error: Could not find a match for 'Point::Point(int)'
		// error: Extra parameter in call to Derived::func(Point)
	vDerived.func(3,4);
		// same errors as above
	}

////////////// SCHNIPP ///////////////////// SCHNAPP //////////////////

Antworten, Vorschlaege, etc. bitte an mich,
ich poste eine Zusammenfassung.

MfG,
        Martin


--
Martin Kneissl   Salzwiese 3, D-W-3200 Hildesheim, Germany
==============   Phone: +49 5121 66414
Technical Details
Message-ID: <0cJ9oB1w164w@paule.han.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!math.fu-berlin.de!zrz.tu-berlin.de!news.netmbx.de!Germany.EU.net!unido!horga!teddy!germany!open!open.de!ruhr.de!agsc!rubikon.han.de!hilde!paule!martin

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!math.fu-berlin.de!zrz.tu-berlin.de!news.netmbx.de!Germany.EU.net!unido!horga!teddy!germany!open!open.de!ruhr.de!agsc!rubikon.han.de!hilde!paule!martin
From: martin@paule.han.de (Martin Kneissl)
Newsgroups: de.comp.lang.c++
Subject: Schwierige Erbschaft
Message-ID: <0cJ9oB1w164w@paule.han.de>
Date: 9 Aug 92 19:37:32 GMT
Organization: Private Site
Lines: 58