what is the syntax for defining virtual functions outside the class body?
class random{
public:
random(int i = 0);
virtual ~random(){};
virtual void print() const;
protected:
int id;
};
is it?
virtual void random::print() {
}
?
Just:
struct foo
{
virtual void bar(void) const;
};
void foo::bar(void) const
{
}
virtual
only goes on the declaration.
In your case:
void random::print() const {
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.