C++ auto type Functions

Introduction

We can deduce the function type based on the return statement value:

auto myintfn() // integer 
{ 
    return 123; //ww  w  . j av a 2s  .  c  o  m
} 

auto mydoublefn() // double 
{ 
    return 3.14; 
} 

int main() 
{ 
    auto x = myintfn(); // int 
    auto d = mydoublefn(); // double 
} 



PreviousNext

Related