P
Philip Pemberton
Hi,
I've just been trying to get some (pretty badly written) code working
on a different compiler. Unfortunately, I've hit a problem. When the
code below is compiled under Borland C++ it (allegedly) works fine. If I
try and compile it with GNU G++, I get the following error report:
bug.cpp: In function `GF2Poly operator%(OddGF2Poly&, OddGF2Poly&)':
bug.cpp:21: call of overloaded `GF2Poly(OddGF2Poly&)' is ambiguous
bug.cpp:3: candidates are: GF2Poly::GF2Poly(const GF2Poly&)
bug.cpp:7: GF2Poly::GF2Poly(long unsigned int = 0)
Could someone please tell me what's going wrong and how I could fix the
problem and get this code to compile (and, preferably, run)? This is a
severely trimmed down version of the code I'm trying to get working.
--- CODE BEGINS
typedef unsigned long UL;
class GF2Poly {
public:
UL p;
GF2Poly(UL x = 0) { p = x; }
operator UL() { return (p); }
};
class OddGF2Poly {
public:
UL p;
operator UL() { return (p); }
operator GF2Poly() { return GF2Poly((p << 1) | 1); }
};
GF2Poly operator% (OddGF2Poly &xx, OddGF2Poly &yy)
{
return GF2Poly(yy);
}
int main(void) {
GF2Poly gfp;
OddGF2Poly ogp1, ogp2;
gfp = ogp1 % ogp2;
return 0;
}
--- CODE ENDS
Thanks,
Phil.
(e-mail address removed) (valid address)
http://www.philpem.me.uk/
I've just been trying to get some (pretty badly written) code working
on a different compiler. Unfortunately, I've hit a problem. When the
code below is compiled under Borland C++ it (allegedly) works fine. If I
try and compile it with GNU G++, I get the following error report:
bug.cpp: In function `GF2Poly operator%(OddGF2Poly&, OddGF2Poly&)':
bug.cpp:21: call of overloaded `GF2Poly(OddGF2Poly&)' is ambiguous
bug.cpp:3: candidates are: GF2Poly::GF2Poly(const GF2Poly&)
bug.cpp:7: GF2Poly::GF2Poly(long unsigned int = 0)
Could someone please tell me what's going wrong and how I could fix the
problem and get this code to compile (and, preferably, run)? This is a
severely trimmed down version of the code I'm trying to get working.
--- CODE BEGINS
typedef unsigned long UL;
class GF2Poly {
public:
UL p;
GF2Poly(UL x = 0) { p = x; }
operator UL() { return (p); }
};
class OddGF2Poly {
public:
UL p;
operator UL() { return (p); }
operator GF2Poly() { return GF2Poly((p << 1) | 1); }
};
GF2Poly operator% (OddGF2Poly &xx, OddGF2Poly &yy)
{
return GF2Poly(yy);
}
int main(void) {
GF2Poly gfp;
OddGF2Poly ogp1, ogp2;
gfp = ogp1 % ogp2;
return 0;
}
--- CODE ENDS
Thanks,
Phil.
(e-mail address removed) (valid address)
http://www.philpem.me.uk/