简体   繁体   中英

syntax for calling virtual functions outside of the class?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM