Saturday, August 10, 2019

Which alternative in C++?



One of the things about programming is that there are several ways to achieve the same goal. During my time coding in C++ I have noticed the following variations in ways to implement certain common features. My question is what are the advantages/disadvantages of each, I understand for the most part how each of them work, but I would like to know which is better in terms of performance, readability, and conformity to standards, as well as acceptability with OOP.



cout vs printf



cin vs scanf




endl vs \n



Thanks


Answer



if your primarily programming lang is C++ and you are doing object oriented programming, then it is going to be cout, cin and endl - hands down :)



it is not a matter of performance, but it is more of a matter of style and coherent coding.



in addition to that you get the perks of having cout, cin work on user defined types as well -- something that is not possible with printf scanf.



No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...