Developing a conversion user-defined-literal - C++ Class

C++ examples for Class:Custom Literal

Description

Developing a conversion user-defined-literal

Demo Code

#include <iostream>

using namespace std;

constexpr long double operator"" _circ ( long double radius )
{
    return radius*radius*3.141592;
}

int main()//from w ww.j a v  a2s  . com
{
    double x = 5.0_circ;

    cout << "The circle's area is: " << x << endl;
    return 0;
}

Result


Related Tutorials