Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code compiles, doesn't link

Status
Not open for further replies.

ziplockenator

Programmer
Jul 26, 2005
1
CA
My problem is that the code does not link, whatever I do. The code compiles fine, but I'm getting vtable and typeinfo errors. My stripped-down code is belown - can someone point out the error?

Code:
(File - "test.cc")
#include "Roads/Vehicle.h"

class test : public Roads::Vehicle {
public:
	test();
	bool hasExit();
	int move();
};

test::test() {
}

bool test::hasExit() {
	return true;
}

int test::move() {
	return 3;
}
 

(File Roads/Vehicle.h)
# ifndef VEHICLE_H_ROADS
# define VEHICLE_H_ROADS

namespace Roads {   
    class Location;
    class Vehicle
    {
    public:
	Vehicle() {};
        Vehicle (int, Location&) {};
        ~Vehicle (){};
                
        // Does this Vehicle have a way out from its current Location?
        virtual bool hasExit ();
    
        // Give this Vehicle a chance to move, return 1 if potential collision.
        virtual int move ();
    };

}
# endif
 
1. Make virtual destructor if your class has virtual member functions.
2. No implementations for virtual (but not pure virtual) members of the class Vehicle - move() and hasExit(). If class Vehicle is an interface only by design, make them pure virtual (append = 0). If not, add implementations of move() and hasExit() for Vehicle. It's ABC of C++...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top