help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "can't find linker symbol for virtual table for 'Value' value"


From: Mike Austin
Subject: Re: "can't find linker symbol for virtual table for 'Value' value"
Date: Sun, 24 Sep 2006 22:35:17 GMT
User-agent: Thunderbird 1.5.0.7 (Windows/20060909)

I realize now that I was passing a pointer to a temporary object.  Live and 
learn..

Mike

Mike Austin wrote:
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;
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]