🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: de.comp.lang.c++
1 messages
1 total messages Started by Martin Kneissl Sun, 09 Aug 1992 19:37
Schwierige Erbschaft
#22
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads