+ 1

Difference between classes and structures?

Can we declare functions in a structures like we do in classes or structures are confined only for different data types?

22nd Jul 2019, 5:07 PM
Deepak Chekuri
3 Answers
+ 7
Yes struct can have methods. The members in a struct are public by default and in a class they are private by default.
22nd Jul 2019, 5:45 PM
James
James - avatar
0
In class all the members are private and in structure all members are public this is different
23rd Jul 2019, 4:28 AM
Mihir Dasani