vendredi 24 juillet 2020

How to declare a function using assignment operator?

This is my code. Every time I try to compile it, it gives me this error
expected primary-expression before 'float' at line 3

#include<iostream>
using namespace std;
auto fun = (float x){
    return 1/(1-x);
};
int main(){
    auto x=fun(0.5);
    cout<<x;
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire