I am getting the following compile error when compiling the code below:
1 2 3
func_ptr.cpp: In function ‘constdouble* f1(constdouble*, int)’:
func_ptr.cpp:11:17: error: cannot convert ‘double’ to ‘double*’ in initialization
double * d{0.0};
Can anybody help me understand why, as I thought I was returning a pointer ?
1 2 3 4 5 6 7 8 9 10 11 12 13
1 #include <iostream>
2
3 // f1() returns a pointer to a double
4 constdouble * f1(constdouble [], int);
5
6 int main() {
7 return 0;
8 }
9
10 constdouble *f1 (constdouble p[], int i) {
11 double * d{0.0};
12 return d;
13 }