Name: Anonymous 2011-11-25 17:08
Hey there /prog/
How could I use the "virtual" type for variables instead of just methods?
For example, I have:
BaseClass.h
MyClass.h
Obviously this currently doesn't work, as I don't believe I can use the virtual keyword for my integer. How could I set this up so that it will work like the other virtual methods?
How could I use the "virtual" type for variables instead of just methods?
For example, I have:
BaseClass.h
#ifndef BASECLASS_H
#define BASECLASS_H
class BaseClass
{
public:
virtual int myInt;
virtual void setup() = 0;
virtual void test() = 0;
};
#endifMyClass.h
#include "BaseClass.h"
class MyClass : public BaseClass
{
public:
int myInt;
void setup();
void test();
};Obviously this currently doesn't work, as I don't believe I can use the virtual keyword for my integer. How could I set this up so that it will work like the other virtual methods?