0

hi,
i know structures are basically used for holding data members whereas classes can hold both functions and data members.
but contrary to the definition of structures can they also hold functions??
i read that they can but there wasn't any explanation about it.
hopefully,some of few can come up with the explanation.

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by sahil1991
0

aCTUALLY in C language structures cannot hold functions.

But when u come to c++, there is very little difference between a structure and a class.

U can have functions in Structures in C++ and u can implement many OOPS concepts in structures, the same way as in a class, except few concepts ofcourse.

So the Bottom line is:
In C Structures cannot have functions
In C++ Structures can contain Functions.

Hope this helps

0

In C structures can hold pointers which can point to functions...So in a way, C structures can hold(point to) functions..

Edited by gerard4143: n/a

0

In C structures can hold pointers which can point to functions...So in a way, C structures can hold(point to) functions..

Yes! I forgot that.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.