I'm prototyping a small runtime vm, and I'm experiencing a strange crash and error message. In gdb, I get these messages when I inspect _value->value() (full source at bottom):

"can't find linker symbol for virtual table for 'Value' value"
"found 'std::ostream::operator<<(long)' instead"

I'm not sure what's going on here. I do pass a 'this' as a reference to Value itself, maybe that is what is confusing g++?

Thanks,
Mike

==========

#include <iostream>
using namespace std;

class Message;

class Value {
  public:
    Value( long value ) : _value( (Value*) value ), _type( 1 ) {}
    Value( Value* value, int type ) : _value( value ), _type( type ) {}

    virtual Value value() {
      cout << _type << endl;
      if( _type == 1 ) {
        return (long) _value;
      } else {
        return _value->value();
      }
    }

    Value* _value;
    int    _type;
};

class Symbol : public Value {
  public:
    Symbol( long value ) : Value( this, 2 ) {}

    virtual Value value() {
      return 0L;
    }
};

const Symbol SIN = 100;
const Symbol A = 101;

class Message : public Value {
  public:
    Message( Value selector ) : Value( this, 3 ) {}
    Message( Value selector, Value arg1 ) : Value( this, 3 ) {}

    virtual Value value() {
      cout << "Message" << endl;
      return 0L;
    }
};

Value program[] = {
  Message( A ),
  Message( 10L, 10L )
};

int main() {
  cout << program[0].value()._value << endl;
}
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to