[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Are methods in structs really bad and why?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 15
Thread images: 2

File: Screenshot_2017-03-01-10-50-05.png (126KB, 1280x720px) Image search: [Google]
Screenshot_2017-03-01-10-50-05.png
126KB, 1280x720px
Are methods in structs really bad and why?
>>
>>59178578
concerning c++
>>
final bump
>>
1. Structs are more of a c thing, in c++ you should use classes

2. In c it is fine to have methods inside structs
>>
Structs in C++ are only really intended for Plain Old Data
When you start adding methods to a struct it's usually a sign you're starting to make a Class
>>
>>59178578
I don't really like it. Make it a class if it holds more than just data.
>>
>>59178578
No, ignore these retards.
>>
>>59180394
1. There are some uses for structs in C++. In structs everything is public by default, which I like to use if I have something that's just pure data, where every field should be accessible.

2. C doesn't have methods, only functions. And you can't have functions in structs in C, only function pointers, which is the way to do OOP in C btw.
>>
>not using interfaces

cucks.
>>
>>59182012
Ya I forget you have to use function pointers in c structs
>>
>>59180394
>Structs are more of a c thing, in c++ you should use classes
the only difference between structs and classes in c++ is that classes are private by default.

There's no reason to use either by default in C++. Don't leave your accessors implicit.
>>
>>59182012
>C doesn't have methods, only functions
C doesn't have functions, only procedures

>And you can't have functions in structs in C, only function pointers, which is the way to do OOP in C btw.
vtables are a better way to do it
>>
>>59183033
>I don't know C
opinions discarded
>>
File: 1461843969412.jpg (166KB, 1312x1014px) Image search: [Google]
1461843969412.jpg
166KB, 1312x1014px
>>59183048
>>
>>59183033
>C doesn't have functions
but it does nigga
Thread posts: 15
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.