can we declare functions in structures in turbo c?
if i declare it shows an error that functions can't be declared within a struct or union.
can we declare functions in structure in turbo c ?need help!
Page 1 of 1
3 Replies - 1712 Views - Last Post: 19 September 2009 - 12:05 PM
#1
can we declare functions in structure in turbo c ?
Posted 19 September 2009 - 12:07 AM
Replies To: can we declare functions in structure in turbo c ?
#2
Re: can we declare functions in structure in turbo c ?
Posted 19 September 2009 - 12:25 AM
thats what a structure means, you cannot declare functions in structures...
however, you can do it in C++ (at lesat i have done it using borland turbo c++), but it is simply not done and the C model is followed so that difference always remains between classes & structures.
however, you can do it in C++ (at lesat i have done it using borland turbo c++), but it is simply not done and the C model is followed so that difference always remains between classes & structures.
This post has been edited by aks29921: 19 September 2009 - 06:35 AM
#3
Re: can we declare functions in structure in turbo c ?
Posted 19 September 2009 - 06:25 AM
Yea using C you cannot declare functions into struct read this might help
http://www.dreaminco...topic126236.htm
http://www.dreaminco...topic126236.htm
#4
Re: can we declare functions in structure in turbo c ?
Posted 19 September 2009 - 12:05 PM
Structures in C can not have functions -- they CAN have function pointers if you really want but in general this is not what you would be looking for.
If you have Turbo C then you should also have Turbo C++ (same compiler). Just rename the file from .c to .cpp and recompile.
If you have Turbo C then you should also have Turbo C++ (same compiler). Just rename the file from .c to .cpp and recompile.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|