🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by David Franke Fri, 06 Oct 1989 17:53
Attempt to define virtual base class generates error
#477
Author: David Franke
Date: Fri, 06 Oct 1989 17:53
39 lines
1839 bytes
	In the example below, class definition B compiles when inheriting
	"public A" but results in a compiler generated error when compiled
	with "virtual public A", as shown below.  Using g++ 1.36.0- release
	of 10/2.


 
[2.51]lynx) cat test.cc 
 
class A { 
 public: 
  int i; 
  int j; 
 
  A(int val1 = 100, int val2 = 200) : i(val1), j(val2) {} 
}; 
 
class B : virtual public A { 
 public: 
  int k; 
 
  B(int val = 40) : A(42,43), k(val) {} 
}; 
 
[2.52]lynx) make -f test-makefile 
/usr/local/gnu/1.36/bin/g++ -c -g -B/usr/local/gnu/1.36/lib/gcc-  -I/usr/local/gnu/1.36/lib/g++-include -v test.cc -o test.o 
gcc version 1.32 
 /usr/local/gnu/1.36/lib/gcc-cpp -+ -v -I/usr/local/gnu/1.36/lib/g++-include -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 test.cc /tmp/cca08337.cpp 
GNU CPP version 1.36 
 /usr/local/gnu/1.36/lib/gcc-cc1plus /tmp/cca08337.cpp -quiet -dumpbase test.cc -g -version -o /tmp/cca08337.s 
GNU C++ version 1.36.0- (based on GCC 1.35.99) (68k, MIT syntax) compiled by GNU C version 1.36. 
default target switches: -m68020 -mc68020 -m68881 -mbitfield 
test.cc: In method B::B (int (=  40 )): 
test.cc:14: `k' fails to be an aggregate typedef 
*** Error code 1 
make: Fatal error: Command failed for target `test'
 David Franke, MCC CAD Program | ARPA: franke@mcc.com | Phone: [512] 338-3641
 UUCP: {uunet,harvard,gatech,pyramid}!cs.utexas.edu!milano!cadillac!franke
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