Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Virtual integer

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

#ifndef BASECLASS_H
#define BASECLASS_H
class BaseClass
{
    public:
        virtual int myInt;
        virtual void setup() = 0;
        virtual void test() = 0;
};
#endif


MyClass.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?

Name: Anonymous 2011-11-25 17:23

Accessors.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List