From: Gregg Newsgroups: comp.os.msdos.djgpp Subject: Simple problem with virtual functions Date: Thu, 16 Oct 1997 21:19:32 -0400 Organization: Cybernex Inc. Lines: 41 Message-ID: <3446BD23.FFE9A31C@gate.cybernex.net> NNTP-Posting-Host: 207.198.208.159 Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------E0C6ADEDAD076EA1F3020476" To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk This is a multi-part message in MIME format. --------------E0C6ADEDAD076EA1F3020476 Content-Type: text/plain; charset=us-ascii Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit I'm a student stuck on this problem. The attached short portion of a C++ program won't let me invoke the constructor in "Var" from main as long as the class Bexp contains virtual methods. The error I get points to the last line and says " undefined reference to Var:Var(char *)" Almost all of the code is given (I must add to it but can't get past this problem. I am not supposed to alter main or workout. When I remove the "virtual labels" the constuctor works but "workout" won't. --------------E0C6ADEDAD076EA1F3020476 Content-Type: application/x-unknown-content-type-cc_auto_file; name="test6.cc" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="test6.cc" I2luY2x1ZGUgPGlvc3RyZWFtLmg+DQojaW5jbHVkZSA8c3RyaW5nLmg+DQogDQp0eXBlZGVm IGNoYXIgKiBzdHJuZzsNCmNvbnN0IGludCBtYXhuYW1zaXo9NTI7ICAgIC8vIG1heGltdW0g bGVuZ3RoIGZvciBhIHZhcmlhYmxlIG5hbWUgKyAxDQoNCmNsYXNzIEJleHByDQp7IA0KICBw dWJsaWM6DQogIHZpcnR1YWwgdm9pZCBwcmludF9tZSgpID0gMDsNCiAgdmlydHVhbCBib29s IGV2YWwoKSA9IDA7DQogIHZpcnR1YWwgQmV4cHIqIG5lZ2F0ZSgpID0gMDsNCiAgIA0KfTsN Cg0KY2xhc3MgVmFyIDogcHVibGljIEJleHByIC8vIGEgYm9vbGVhbiB2YXJpYWJsZSAxNg0K ew0KcHJpdmF0ZToNCi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