🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #5530

C++ constructor probleem

#5530
From: Aquila
Date: Wed, 02 Apr 2003 16:51
37 lines
2697 bytes
Voor een project ontwerpen wij een wiskundige library, die een aantal
fundamentele types ondersteunt zoals matrix, vector, rational, complex en
verylong (onbegrensde int). Alleen die laatste klasse is niet
getemplatiseerd. Nu krijgen we problemen in onze code als we een
matrix<complex<rational<verylong>>> proberen te maken. Het probleem is
namelijk dat gcc plots verward raakt, en niet meer kan kiezen tussen de
copyconstructor en de gewone constructor.
De fout ziet er als volgt uit:

testmatrix.cxx: In member function `void Test::TestMatrix::testConstructor()
   [with AT = WiskTypes::Complex<WiskTypes::Rational<WiskTypes::VeryLong>
>]':
testmatrix.cxx:23:   instantiated from `void
Test::testTypes(CppUnit::TestSuite*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >) [with AT =
WiskTypes::Complex<WiskTypes::Rational<WiskTypes::VeryLong> >]'
testmatrix.cxx:73:   instantiated from here
testmatrix.cxx:92: no matching function for call to `
   WiskTypes::Complex<WiskTypes::Rational<WiskTypes::VeryLong>
>::Complex(int)'
../complex.h:54: candidates are: WiskTypes::Complex<AT>::Complex(const
   WiskTypes::Complex<AT>&) [with AT =
   WiskTypes::Rational<WiskTypes::VeryLong>]
../complex.h:48:                 WiskTypes::Complex<AT>::Complex(AT =
(AT)(0),
   AT = (AT)(0)) [with AT = WiskTypes::Rational<WiskTypes::VeryLong>]

Waarbij in testmatrix op die plaats WiskTypes::Matrix<AT>(4,6,AT(7)) staat,
en in complex.h dus de declaraties staan van respectievelijk de
copyconstructor en een gewone constructor op basis van 2 argumenten AT.

De vraag is dus: waarom gaat dit fout, en wat kunnen we eraan doen?
-- 
Pleased to meet you
Hope you guess my name
But what's puzzling you
Is the nature of my game
Technical Details
Message-ID: <b6f4fd$3r9$1@reader10.wxs.nl>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!news2.euro.net!news2.euro.net!newsfeed.wxs.nl!textnews.wxs.nl!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: fcea4,cf54256025f2c16e,start
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-04-02 08:51:17 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!news2.euro.net!news2.euro.net!newsfeed.wxs.nl!textnews.wxs.nl!not-for-mail
From: Aquila <Braempje@Netscape.Net>
Newsgroups: be.comp.programming
Subject: C++ constructor probleem
Date: Wed, 02 Apr 2003 18:51:06 +0200
Organization: Planet Internet
Lines: 37
Message-ID: <b6f4fd$3r9$1@reader10.wxs.nl>
NNTP-Posting-Host: 81.11.134.99
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
X-Trace: reader10.wxs.nl 1049302317 3945 81.11.134.99 (2 Apr 2003 16:51:57 GMT)
X-Complaints-To: abuse@planet.nl
NNTP-Posting-Date: 2 Apr 2003 16:51:57 GMT
User-Agent: KNode/0.7.2