umrigar@bingvaxu.cc.binghamton.edu (Zerksis D. Umrigar) (08/14/90)
When I attempt to run the following program under Borland's Turbo C++ v1.0 under MS-Dos v3.1 on a PC-AT, I get the error messages shown below. The program works fine under GNU's g++ 1.35. Am I correct in surmising that there is a bug in the compiler, or am I missing something here? Thank you. -zerksis umrigar ====== ------------------------CUT HERE---------------------------------- /* The following program is an abstract program which exhibits what appears to be a bug in TCpp 1.0. The compiler signals an error when the LAST default parameter for a constructor is initialized by a constructor for some other class. A workaround is to add an extra dummy default parameter of some predefined type like int. Note also that this program works fine under FSF's GNU g++ v1.35 --- the only change required is to change iostream.h to stream.h. */ #include <iostream.h> class Y { int val; public: Y(int a = 0) { val = a; } int get() { return val; } }; class X { friend ostream& operator<<(ostream&, X&); int a; public: X(int i) { a = i; } X(Y y = Y(0)/* , int dummy=0 */ ) { a = y.get(); } // **Problem here!* void f(Y y = Y(0)); //Note that a non-constructor handles default //parameter constructor initialization ok. }; void X::f(Y y) { a += y.get(); } ostream & operator<<(ostream & os, X& x) { return os << x.a; } main() { Y y1(4); //y1.val==4; X x1(2), x2, x3(y1); //x1.a==2; x2.a==0; x3.a==4; x1.f(y1); x2.f(y1); //x1.a==6; x2.a==4; cout << x1 << " " << x2 << " " << x3 << "\n"; //Should print "6 4 4\n". } /* COMPILATION LOGS: --LOG OF COMPILATION WITH dummy PARAMETER COMMENTED OUT: Turbo C++ Version 1.00 Copyright (c) 1990 Borland International noerror.cpp: Error noerror.cpp 28: ) expected Error noerror.cpp 43: Could not find a match for 'X::X()' in function main() Error noerror.cpp 43: Could not find a match for 'X::X(Y)' in function main() *** 3 errors in Compile *** Available memory 102528 --LOG OF COMPILATION WITH dummy PARAMETER INCLUDED. Turbo C++ Version 1.00 Copyright (c) 1990 Borland International noerror.cpp: Warning noerror.cpp 28: Parameter 'dummy' is never used in function X::X(Y,int) Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International Available memory 109552 --Program executes and prints 6 4 4 --as expected. */ ------------------------------------------------------------------
ccastdf@prism.gatech.EDU (Dave) (12/06/90)
Whenever I set the text mode to 50 collumns, cout still scrolls it at 24 collumns. Is there any way to make it scroll at 50 like it should? btw, I do a textmode(C4350); Thanks, Dave -- David Frascone Georgia Institute of Technology, Atlanta Georgia, 30332 uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!ccastdf Internet: ccastdf@prism.gatech.edu