[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Why is it bad to use "C style" in C++? Like the c standard
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 11
Thread images: 2
File: line.jpg (67 KB, 800x600) Image search: [Google]
line.jpg
67 KB, 800x600
Why is it bad to use "C style" in C++? Like the c standard library functions, char arrays instead of strings, malloc instead of new keyword etc?
>>
File: tfw.jpg (50 KB, 446x522) Image search: [Google]
tfw.jpg
50 KB, 446x522
blame GNU.
>>
>>55194996

If you want to use the C code style just fucking code in C you idiot.
>>
>>55195240
Then why bother having it included in the language at all?
>>
>>55196030
C++ isn't really a language all its own; it was an extension for C that grew into what it is today.
>why is it bad to use "C style in C++
Because it is. In every way. Less efficient, more effort, you're reinventing the wheel, etc. It's just a bad idea.
>>
>>55196030
because c++ is built on top of c
>>
Because C++ is full of bloat, malloc is faster than new, char array is faster than string etc, but sometimes that one C++ feature is just too useful to skip.
>>
>>55196097
So, again, why is using the base part of the language necessarily bad?
>>
>>55196252
because then you'd be writing c code with a c++ wrapper.
it's the same reason as why you _usually_ don't write assembler code in a c program (there are some reasons to do i though).
also, some compiler checks and probably runtime checks wouldn't work.
>>
>>55196392
C++ wrapper? What are you talking about? All C keywords are still a part of C++. Unless you're using some garbage compiler with no support, I'm not sure what kind of problems you're going to run into here. Can you give me an example?
>>
>>55196481
c++ has some kind of type safety, while c almost doesn't know what datatypes even are.
for c++ you have to cast malloc while you never should in c

for what reason would you want to write c code in c++ ? why not just c ?
Thread replies: 11
Thread images: 2

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.