Tip Bank

DevX - Software Development Resource

The ‘final’ class in C++

Suppose you need to prevent the derivation of a class?like in the final classes of Java. Simply make the constructor of the class private. Here’s an example: class final{private: final(){}

DevX - Software Development Resource

Structs with Care: Boxing

Consider an employee service, say in an SOA-based implementation, which exposes the following method: Employee getEmployeeInfo(int employeeId) Looking at this signature, Employee can be defined as struct because it would

DevX - Software Development Resource

Call a Private Method of a Class

Use this polymorphic technique to cheat the compiler and expose private information: See the code below.class A{public: virtual void f2() { printf(“in A::f2 “); }};class B: public A{private: void f2(int