devxlogo

How to Disable Further Derivation of a Class

How to Disable Further Derivation of a Class

In some rare cases, it is useful to disallow further derivation of a class. Classes that implement system API or sensitive security management are good examples for that. Declaring the constructor as private prohibits any further derivation of that class.

 class Firewall { 	public: 		bool isAdressValid( const IP_address& ip);private: Firewall() {}//private constructor disables further derivation from this class};

If you’re familiar with Java, it has the same effect as declaring a class as final.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist