>>1,2
Well, refs are nice but remember that once that fucking thing is ref'd in your new class you have to keep track of the lifecycle of aaaalllll the motherfucking instances that use it. So there's something to be said for copying - if you're using the same string for a bunch of instances, reference, and if not, probably copy.
I think this article somewhat missed the boat by not mentioning the D programming language. Learning C first does not make other languages easier to learn. Yes everyone currently uses C and C++ for their low level code. But they are obsolete and frankly masochistic languages with error prone syntax. D will eventually get recognized for it's efficiency and power, and will displace them. So many people just parrot the same spiel about how students should learn languages that are currently hot, but are really old, outdated, and extremely poorly suited to handle tangible problems like concurrency. As long as everyone keeps learning and using antiquated languages everyone will suffer with substandard software and code bases that could be a lot cleaner and easier to maintain. Students will learn bad habits, and users have to cope with more bugs then they have to. Coffee and headaches for everyone. Progress isn't about what everyone has always done, it's about what they're going to do tomorrow. And what programming language you learn or use shouldn't be based on sheer popularity, but based on what is the best tool for the job. And in our now concurrent environment, many languages are dinosaurs.
Name:
Anonymous2013-08-29 0:06
>>3 Superior code is below: my_class::my_class(std::string const& description)
: description_(description) {}
What are you guys still in 90's?
The real correct answer is:
MyClass::MyClass (std::string description)
: description(std::move(description)) {}
It works optimally whether passed an l-value or r-value and works for const char * as well.