#code review, just making sure its correct (beginner)
35 messages · Page 1 of 1 (latest)
so, using a string literal there makes no sense
using namespace std is also generally not the best practice
also, prefer newline characters over std::endl
Something like this would be better
Notes:
1- Using namespace std tends to bad practice, better to get accustomed with std:: prefix.
2- Cin is for Console input stream, or just reading from the console, using the insertion operator ">>" makes so you "save" the stream data in a variable.
3- std::endl at the last line is to jump to the next line.
bro c++ datatypes are so bloated im not gonna lie
also doesent std::enl flush the buffer
yes it does
why?
std::string
string should just be
a
common datatype token
Str
is what ppl use
i should be able to just declare strings the same way as intergers, booleans, everything else.
you mean it should be a primitive type? well, no it shouldn't
if you understand how memory layout works like you'd know why it is the way it is
also that has nothing to do with "being bloated"
besides, std::string is required to implement small string optmization, so if anything it is the opposite of that
Wait, how would you use the string implementation from another library then if you don't like the one from std library? That would be confusing.
If string was built in, how would you use the string implementation from another library if you don't like the one from std library? That would be confusing.
no
you could just pop the library before it
like
string
or
library::string
No, it doesn't make sense. You shouldn't be forced to use the library:: prefix everywhere just to use a string. C++ gives you a choice. If you want to use the std implementation in your cpp file, you write "using std::string", if you want to use the library implementation, you write "using library::string". If you prefer clarity, you use "std::" or "library::" prefix every time. That's one of the key differences between C++ and other languages - it gives you a choice instead of forcing solutions.
i have a 6k program that is entirely made with using namespace std and it works like a charm, yo can keep using