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

C++ Equivalent to the Java 'instanceof' and 'class' Operators

There is no direct equivalent in C++ to the Java 'instanceof' operator, but you can replicate the behavior by testing the result of a 'dynamic_cast'.

Java C++
boolean b = f instanceof Foo;
v = w.class;
bool b = dynamic_cast<Foo*>(f) != nullptr;
v = w::typeid;

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

Additional resource: Java and C++ Equivalents

Copyright © 1997 – 2018 Tangible Software Solutions, Inc.