Results 1 to 6 of 6

Thread: C++: it's good programing use functions on a struct?

  1. #1

    Default C++: it's good programing use functions on a struct?

    i know the structure accept functions, but it's a good practice doing it?

  2. #2
    Controller Man ulaoulao's Avatar
    Join Date
    Dec 2005
    Location
    FL
    Posts
    3,338
    Blog Entries
    2

    Default Re: C++: it's good programing use functions on a struct?

    The only difference from a stuck to a class is how it handles memory. Also the their default access level is public where classes are private. In C it is a necessity but c++ it is interchangeable with a class. Some use Structs for short structures rather then a class. If you are making a car you would want a glass but in that car you may have a seat and you can make 4 seats (structs) in it. This is a bit more readable some say. Though ultimately it is up to you in how you want to do it. It is perfectly OK to put a class in a class.

    So in that, sure using functions in a struct is no different then a class.
    Last edited by ulaoulao; June 5th, 2019 at 14:04.
    Original, the only way to play.

    Forums
    main page - Working controllers

  3. #3

    Default Re: C++: it's good programing use functions on a struct?

    thank you so much for correct me...
    i did the question because i started, on past, from Turbo Pascal and then Visual Basic... their structures don't accept functions... so i did the question
    i never knew that the C structures accepted functions.. thank you so much for all

  4. #4

    Default Re: C++: it's good programing use functions on a struct?

    Quote Originally Posted by cambalinho View Post
    thank you so much for correct me...
    i did the question because i started, on past, from Turbo Pascal and then Visual Basic... their structures don't accept functions... so i did the question
    i never knew that the C structures accepted functions. Tutuapp 9Apps ShowBox . thank you so much for all
    This is a bit more readable some say. Though ultimately it is up to you in how you want to do it. It is perfectly OK to put a class in a class.

    So in that, sure using functions in a struct is no different then a class.
    Last edited by GASIYAT; September 16th, 2019 at 20:32.

  5. #5

    Default Re: C++: it's good programing use functions on a struct?

    thank you so much for all to all

  6. #6

    Default Re: C++: it's good programing use functions on a struct?

    Quote Originally Posted by GASIYAT View Post
    This is a bit more readable some say. Though ultimately it is up to you in how you want to do it. It is perfectly OK to put a class in a class.Download showbox apk So in that, sure using functions in a struct is no different then a class.
    nice answer

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •