3 Replies - 1712 Views - Last Post: 19 September 2009 - 12:05 PM Rate Topic: -----

#1 simriti  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 12-August 09

can we declare functions in structure in turbo c ?

Post icon  Posted 19 September 2009 - 12:07 AM

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.
Is This A Good Question/Topic? 0
  • +

Replies To: can we declare functions in structure in turbo c ?

#2 aks29921  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 84
  • View blog
  • Posts: 230
  • Joined: 24-August 09

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.

This post has been edited by aks29921: 19 September 2009 - 06:35 AM

Was This Post Helpful? 1
  • +
  • -

#3 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

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
Was This Post Helpful? 0
  • +
  • -

#4 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2209
  • View blog
  • Posts: 9,183
  • Joined: 18-February 07

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1