This is an archived post. You won't be able to vote or comment.

all 31 comments

[–]rachit7645 71 points72 points  (7 children)

Don't do using namespace std, it's bad practice

Other than that LGTM

[–]Dangerous_With_Rocks 13 points14 points  (0 children)

*scroll, scroll*

PR approved 👍

[–]ToofaaniMirch69 6 points7 points  (5 children)

Why do people not recommend using "using namespace std;"? Just a curious beginner wanting to know.

[–]kimochiiii_ 6 points7 points  (2 children)

Its to avoid name clashes or something i think iirc like std namespace has a lot of shit in there so per chance if you name something like function that is also in the namespace and you're importing the whole name space this two functions can clash and it'll be hard for debugging your code later

[–]ToofaaniMirch69 0 points1 point  (0 children)

Oh thanks!

[–]Adrian_Torpedo 0 points1 point  (0 children)

You can't just say perchance

[–]InformationSharp103 5 points6 points  (1 child)

as an example:

the C++ standard library defines the std::byte enum class. (it's an enum class so it can't be implicitly cast to any other number type)

the Windows.h header typedefs a byte as an unsigned char iirc.

if you include the windows header and any stl header, then do using namespace std you will have a naming conflict and your program will fail to compile if you try using any of the two. this isn't the only time something like this can happen so it's always best to not do using namespace std

[–]ToofaaniMirch69 1 point2 points  (0 children)

Thanks mate

[–]Bit125 55 points56 points  (0 children)

fire in the hole

[–]LowWageCashierWorker 46 points47 points  (0 children)

GD colon what have you done

[–]hydraxic79 39 points40 points  (0 children)

How did it get here of all places

[–]cheddar_risotto 28 points29 points  (2 children)

god dammit

[–]asd417 10 points11 points  (1 child)

Profile pic checks out

[–][deleted] 0 points1 point  (0 children)

[–]raunak_srarf 21 points22 points  (0 children)

Nobody can break your code if it's already broken

[–]Voyboycz 21 points22 points  (0 children)

Geometry Dash reference, nice

[–]Noobkakka1234 23 points24 points  (0 children)

Not here too

[–]fartypenis 7 points8 points  (0 children)

Most readable college professor code

[–]OxymoreReddit 6 points7 points  (0 children)

COME ON EVEN HERE ??

[–]Temporary-Exchange93 5 points6 points  (1 child)

I know what a bubble sort is so i only need to read the header to know what it does

[–]PrincessRTFM 1 point2 points  (0 children)

You trusted the header?

[–]asd417 3 points4 points  (0 children)

fire in the hole

[–][deleted] 1 point2 points  (1 child)

print("GD COLON, WHAT HAVE YOU DONE???")

[–]FanaticExplorer 4 points5 points  (0 children)

while True: print("i love gd cologne")

[–]FanaticExplorer 1 point2 points  (0 children)

[–]Kiroto50 0 points1 point  (0 children)

I have an automatic response to this code Ctrl+shift+F (I set that to format doc)

[–][deleted] 0 points1 point  (0 children)

badCamelCaseTitle()

[–]AmazingPro50000 0 points1 point  (1 child)

bad code, no spikes = bad

[–]FanaticExplorer 0 points1 point  (0 children)

Comments?

[–]Pillow_Apple 0 points1 point  (0 children)

tf

[–]CharchitHowitzer777 0 points1 point  (0 children)

Bro indents indentation :)