[GiNaC-list] let_op() and index

mdias at ift.unesp.br mdias at ift.unesp.br
Thu Feb 24 14:06:40 CET 2005


Hi guys, 

Wrinting the code below I can define op() function, but I cant define let_op()
(I now, it seems to be a very simple problem...)


#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
class covdiff : public indexed{
  GINAC_DECLARE_REGISTERED_CLASS(covdiff,indexed)
    public:
	idx index;
        ex arg;
  covdiff(const ex, idx) ;
 ex &  let_op(size_t i);
 size_t nops() const;
}
ex covdiff::op(size_t i) const
{
  switch (i){
  case 0:
    return arg;
  case 1:
    return index;
  default:
    throw std::range_error("covdiff::op(): no such operand");
  }
}


ex & covdiff::let_op(size_t i)
{
ensure_if_modifiable();
 switch (i){
  case 0:
    return arg;
     case 1:
    return index; <--------error occur here
  default:
    throw std::range_error("covdiff::op(): no such operand");
  }
}

test.cpp: In member function `virtual GiNaC::ex& covdiff::let_op(unsigned int)
   ':
test.cpp:88: error: invalid initialization of reference of type 'GiNaC::ex&' 
   from expression of type 'GiNaC::idx'


Thanks,





Marco

-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/




More information about the GiNaC-list mailing list