"invalid conversion from 'char (*)()' to 'char'" ???

Hello!
Please, what means actually
char(*)()
???

What conversion do they think about?

Please, if someone knows the answer!!!
MANY THANKS!!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<iostream>
using namespace std;

char f1(){
   char k='o';
return k;
}

int main(){
   cout<<"aaa"<<endl;
   char t=f1;
   cout<<t;
return 0;
}

In function 'int main()':
Line 11: error: invalid conversion from 'char (*)()' to 'char'

Last edited on
its because f1() is a function but you tried o access it as a variable.
char t = f1();
Thanks!!!
But, what in the program was that complier ment with the expression
char (*)()
?

Did it mean:char (*)()=f1?(line 11) or f1() (line 4)?
IOW: what is FROM, and what is TO?(exactly!!!)

What is ment to be (*) and what is ment to be ()? Is the last one () from f() is the 4th line? (I mea, () from my input, or just suspected ()?)

p.s. This is ment to be a very hard question, at least I think!

MANY THANKS!!!
Last edited on
But, what in the program was that complier ment with the expression
char (*)()

It's a pointer to a function. The syntax of these is a bit weird if you've never seen them before, but I'm sure your textbook will include information about them.

When you use the name of a function on it's own, without any parentheses, then it's treated as a pointer to a function.
Topic archived. No new replies allowed.