• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

C++ Equivalent to Java Constructors & Finalizers

The implementation of the 'close' method in the Closeable interface can be converted to a C++ destructor, but this is not exactly equivalent.

Java C++
class Foo implements java.io.Closeable
{
    public Foo()
    {
        this(0);   //call to other constructor
    }
    public Foo(int i)
    {
    }

    public final void close()
    {
    }
}
class Foo
{
public:
    Foo() : Foo(0)   //call to other constructor
    {
    }
    Foo(int i)
    {
    }

    ~Foo()   //destructor
    {
    }
};


Use Java to C++ Converter to convert from Java to C++.     

Additional resource: Java and C++ Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.