C++C++17Introduction to C++Learn C++

Learn About Explicit Specifier in C++ Classes

What is Explicit Specifier ? How can we use Explicit Specifiers in Classes ? Here are the explanations with examples below,

Classes are are the blueprint that has properties and methods for the objects and they are user-defined data types that we can use in our program, and they work as an object constructor. Classes defined in C++ by using keyword class followed by the name of the class.

Objects are an instantiation of a class, In another term. In C++ programming, most of the commands are associated with classes and objects, along with their attributes and methods. 

The Explicit Specifier defined with ‘explicit‘ statement and it can be used alone or with a constant expression in C++ Classes that the function is explicit if and only if that constant expression evaluates to true. It specifies that a constructor or conversion function or deduction guide is explicit. It cannot be used for implicitly conversions and copy initialization.

Syntax,

An example in a Class,

An example with ‘operator’ statement in a Class,

The explicit specifier may only appear within the decl-specifier-seq of the declaration of a constructor or conversion function within its class definition.

Get started building powerful apps with C++Builder!

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++17Language FeatureLearn C++

How To Use Skia Images in C++ Builder?

C++C++17Code SnippetGame DevelopmentLanguage FeatureLearn C++

What Is Skia In Modern C++?

C++C++17Learn C++

How To Use Skia in C++ Builder 12?

C++C++17C++20Introduction to C++Language FeatureLearn C++Syntax

Learn How To Use Clamp (std::clamp) In Modern C++ 17 and Beyond