Question #268856

Develop a C++ program having a class called mathematics used to calculate sum for two integer values. The program should create an object of the class in main( ) program.


Expert's answer

class Math<T> {
   static T sum(T a, T b) { return a + b; }

   public static void main(String[] args) {
      System.out.println(Math<int>.sum(4, 6));
   }
}
LATEST TUTORIALS
APPROVED BY CLIENTS