Computer Science, asked by Dipak8726, 9 months ago

Can we declare function inside structure of C Programming?

Answers

Answered by jhangir789
1

No, it is not possible to declare a function inside a struct in C.

  • But you can do so in C++, rather you can have a function pointer in a “struct” in C Language.

Can we have a function inside structure of C programming?

  • Member functions inside the structure, Structures in C cannot have member functions inside a structure but Structures in C++ can have member functions along with data members.

Can we use constructor in structure?

  • Struct can include constructors, constants, fields, methods, properties, indexers, operators, events & nested types.
  • Struct cannot include a parameterless constructor or a destructor. struct can implement interfaces, same as class.
  • Struct cannot inherit another structure or class, and it cannot be the base of a class.

Hence, No, it is not possible to declare a function inside a struct in C.

Learn more about C programming here,

https://brainly.in/question/25399054?msp_poc_exp=5

#SPJ2

Similar questions