+ 18

Is it possible to include function inside a structure in C language

4th May 2019, 9:53 AM
Frozen❤
Frozen❤ - avatar
8 Antworten
+ 12
Not possible...The idea is to put a pointer to a function inside the struct. The function is then declared outside of the struct. This is different from a class in C++ where a function is declared inside the class.
4th May 2019, 10:14 AM
Bubbly🎀🎀🎀
Bubbly🎀🎀🎀 - avatar
+ 5
No... I think so
4th May 2019, 9:58 AM
Shining Star
+ 5
~ swim ~ does the ability for a struct to contain a function pointer make C pseudo object oriented?
6th May 2019, 7:19 AM
Sonic
Sonic - avatar
+ 4
Not possible
9th Jun 2019, 3:37 PM
Keerthy Sivadas
Keerthy Sivadas - avatar
+ 3
Woow
4th May 2019, 11:13 AM
Maryam
Maryam - avatar
+ 3
Funny I was just thinking today that a structure of function pointers would be a good way to provide a common interface for different implementations.
4th May 2019, 12:04 PM
Jared Bird
Jared Bird - avatar
+ 3
I think you can't. only pointers are allowed to include according to my knowledge
14th May 2019, 3:56 AM
Tharani Dayadhi Karunathialaka
Tharani Dayadhi Karunathialaka - avatar
0
You cannot declare a function in a structure as the structure is itself included in a function i.e. int main() or void main() or in any other function you may declare, and you cannot declare a funtion into another function.
20th Jun 2019, 7:30 AM
procheta bhattacharyya
procheta bhattacharyya - avatar