class Vector(type) { \
protected: \
type* v; \
int v_size; \
public: \
Vector(type)(int s) { v = new type[v_size=(s>0? s: 1)]; }\
... \
Vector(type)& operator=(const type ); \ < A
Vector(type)& operator=(const Vector(type)&); \ < B
... \
};
class NumVec(type) : public Vector(type) { \
public: \
NumVec(type)(int s) : Vector(type)(s) { ; } \
... \
};
...
#define vector NumVec
main()
{
int i, n=5;
vector(double) a(n), b(n), c(n);
a = 1.2;
b = 2.3;
c = a + b;
for (i=0; i<n; i++) cout << a[i] << ", " << b[i] << ", " << c[i] << "\n";
}
------
if main() is like this, I was told that
7 %CC -g test.c
"test.c", line 27: warning: argument 1: double passed as int
"test.c", line 28: warning: argument 1: double passed as int
and using dbxtool, I find that the main() try to call the 2nd operator = ( see
line B above) with a null pointer, not the 1st operator =.
if in main() I write
a.operator=(1.2);
b.operator=(2.3);
then the program runs ok.
I don't understand what the problem is. it seems the compiler did not agree to
assign the first = as the operator which should match the type.
Anyone there can give a help? Thanks in advance.
J. Sun