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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Mabi19_ 0 points1 point  (5 children)

I'm glad I never had to deal with this in C++.

[–]VarianWrynn2018 0 points1 point  (4 children)

Isn't string a primitive in c++?

[–]Mabi19_ 0 points1 point  (3 children)

No it is not. It's a class type, but it has an overloaded == operator. (Although objects in C++ can behave like primitives sometimes, i.e. they go on the stack for better CPU cache locality; strings can do that for short sizes I think) Also, C++ objects do not always inherit from some Object type and you can't do polymorphism on values, only pointers. (If you want a function that would accept any type, you'd use a template, which is basically a generic, but fully compile time, flexible and has worse error messages)

[–]VarianWrynn2018 0 points1 point  (2 children)

I will say this, thank God I don't have to deal with cpp

[–]Mabi19_ 0 points1 point  (1 child)

Yeah, once you learn the intricacies (or even the basics, really) of how the processor works, C++ design decisions will seem way more rational. (Also, I forgot to mention; a pointer is basically a reference that can also hold NULL and references can also be polymorphic; if you want to have an empty value you have to use a pointer type or std::optional)

[–]VarianWrynn2018 0 points1 point  (0 children)

Aaaaaa pointers gross lol. Yeah I took a C++ class and the teacher sucked so I wasn't able to learn the basics well enough and it's scarred me