Tag: java

  • Java to C++

    Many times people from Java endup writing C++ code and vice versa (for vice versa check notes below). This is the beauty of working in such a dynamic/vast programming eco-system. This blog is to help them create an analogy between the two.

    Below we have a sample Java code which we like to convert to C++.

    interface MyInterface {
      void func1();
      int func2(int x, int y);
    }
    
    interface MyAnotherInterface {
      void func3();
      int func4(int x, int y);
    }
    
    abstract class MyAbstract implements MyInterface {
      void func1() {
        System.out.print("In func1");
      }
    }
    
    class MyConcreteClass extends MyAbstract
      implements MyAnotherInterface {
      int func2(int x, int y) {
        System.out.print("func2 x=" + x + ",y=" + y);
      }
    
      void func3() {
        System.out.print("in func3");
      }
    
      int func4(int x, int y) {
        System.out.print("func4  x=" + x + ",y=" + y);
      }
    }
    

    (more…)