• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

C++ Equivalent to the Java 'instanceof' Operator

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; bool b = dynamic_cast<Foo*>(f) != nullptr;

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

Additional resource: Java and C++ Equivalents

Copyright © 2004 – 2021 Tangible Software Solutions, Inc.