+ 22
Can we make Structure in C++ which have Member Function ?
In C it's not possible.
15 Answers
+ 13
Thanks for the Answer to all.
This is helpful for me.
+ 10
Avinesh c++ structure support many features of class... Except they have default member public... And no support for class templates
+ 10
Thanks to all for Answers
This is very helpful for me .
+ 7
https://stackoverflow.com/questions/13125944/function-for-c-struct
Yes we can ,for eg. Follow the link above
+ 7
Yes in C++
+ 7
Yes in C++ it is possible.
But in C, a member cannot be a function. But a function pointer can be a member of a structure in C
+ 4
Saurabh B I'm sorry I didn't knew that since I don't use it. But thanks for letting me know.
+ 3
In C language structures cannot contain functions, C++ have classes and not structures and yes we can have member function in classes.
+ 3
Shubham u should check stack-overflow.. Link is mentioned above... Just don't give wrong answer
+ 3
https://code.sololearn.com/cxH699AB2SVx/?ref=app
Check code for those having doubt....
+ 1
Yes saurabh, i didn't see word 'c++' i assume to be question is asked for c language.
Hey guys i accept my fault.đ
0
No
That's why the concept of class came forth.
It just contain member variables.