I am working on making a 'safetype' abstract class, which will have a complete set of pure virtual operator overloads to help make sure that a class inherited from it is safe to pass to virtual any function. The problem is that I don't know the syntax of a pure virtual operator overload or if any of the operators are unable to be virtualized. Can somebody give me an example of how to write a pure virtual operator, as well as list any operators that cannot be made purely virtual?

Recommended Answers

All 2 Replies

Actually there is little to no reason to make operators virtual, with mild exception to operator=;

As for the syntax you can do this :

struct F{
 virtual F& operator+(const F& f)const = 0;
 //.. and so on

Thank you, that is exactly what I was looking for!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.