Abstract class variables do not need to be reference parameters in C++.
The only thing that makes a class in C++ abstract is if it has a virtual function that must be handled:
virtual void ThisFunctionMustBeHandled() = 0;
So the only requirement when using an abstract class is that any classes derived from it must have definitions for any pure virtual functions.
I know that in c++( when doing object oriented) everything is a pointer to an object, so why is the above an exception? I am thinking it is because abstract classes in C++ can have purely virtual methods, so is this reference pointer used to get us the offset into the portion of the virtual method table for that object?
Not every member that is a class must be a pointer to an object either.
OtherClass other; // Not a pointer
Originally Posted by joemaniaci
Well you access objects in C++ using pointers, with an object of an abstract class, it is a reference, why?
You access objects in C++ using either pointers or references, just like any other variable.
Having a reference to an abstract class is pretty rare, usually you're going to have a reference/pointer/instance to one of the derived classes.
Edited by lordikon - 5/5/11 at 1:36pm
OtherClass other; // An instance of a class
OtherClass& otherRef; // A reference to an instance of a class, reference members are somewhat uncommon by the way.
OtherClass* otherPtr; // A pointer to a class
// Accessing the members