🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c++
Article #116

pointers to virtual functions

#116
From: Tom Lanning
Date: Tue, 25 Mar 1986 23:43
32 lines
1398 bytes
	Is this a bug in my version of cfront, or a natural attribute of
C++? 

	class one {
	public:
		void (*pointer)();
		virtual void x () { cout << "one"; }
		virtual void y () { (*pointer)(); }

		one () { pointer = x; }
	}

	class two : public one {
	public:
		virtual void x () { cout << "two"; }
	}


	When I create an object of class "two", i.e.

		two object;

	and call "object.y ()", I get "one", not "two" like I want, and
	would somewhat expect.  Is this correct?  If "x" is a virtual
	function I would expect "pointer" to point to a "virtual function"
	pointer that changes with each derived class.  Instead it appears
	that the value is fixed when the pointer is assigned a value.  Any
	comments?  Thanks.
-- 

  Tom Lanning   AT&T Bell Laboratories   Columbus OH   43213     614-860-4153
Technical Details
Message-ID: <4298@cbrma.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!cbosgd!cbuxc!cbuxb!cbrma!trl

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 alpha 5/22/85; site cbrma.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!cbosgd!cbuxc!cbuxb!cbrma!trl
From: trl@cbrma.UUCP (Tom Lanning)
Newsgroups: net.lang.c++
Subject: pointers to virtual functions
Message-ID: <4298@cbrma.UUCP>
Date: Tue, 25-Mar-86 18:43:19 EST
Article-I.D.: cbrma.4298
Posted: Tue Mar 25 18:43:19 1986
Date-Received: Thu, 27-Mar-86 01:20:32 EST
Distribution: net
Organization: AT&T-BL, RMAS, Columbus
Lines: 32
Keywords: virtual functions bug