[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
question about reloading assignment operator =
From: |
John W. Eaton |
Subject: |
question about reloading assignment operator = |
Date: |
Sat, 11 Nov 2006 09:11:14 -0500 |
On 11-Nov-2006, wang lei wrote:
| hi all!
|
| my ocatave is 2.9.9 on debian testing.
|
| In make_int.cc assignment operator = is not reloaded. To reload it I add
| these sentences in make_int.cc:
| class octave_integer{
| public:
| ...
| void assign(const octave_integer& t){ scalar = t.scalar; }
| private:
| ...
| };
|
| DEFASSIGNOP(assign, int1, int2){
| CAST_BINOP_ARGS(octave_integer&, const octave_integer&);
| cout << "assignment" << endl;
| v1.assign(v2);
| return octave_value();
| }
|
| DEFUN_DLD(make_int, args, , " ")
| {
| static bool type_loaded = false;
| if(!type_loaded){
| ...
| INSTALL_ASSIGNOP(op_asn_eq, octave-integer, octave_integer, assign);
| ...
| }
| ...
| }
|
| and mkoctfile and type "a=make_int(10);b=make_int(20);a=b;", but nothing
| happened. why?
You can't overload assignment operators. Why do you think you need to
do this?
jwe