My Most Important C++ Aha Moments (2006)
31–40 of 84 posts
Re: My Most Important C++ Aha Moments (2006)
#32> Realizing that C++’s “special” member functions may be declared private Don't do this anymore! Just delete them: MyClass& operator=(const MyClass&) = delete; Private-really-means-deleted was a cool and very useful trick before C++11. So useful, that it was a shame to require secret knowledge and aha moments to use. So they just made it a normal feature of the language. There's also a way to explicitly use the defau…
Come to think of it, the trick to make something private in order to "remove" it is one of these very few areas where C++ makes you pay for something you don't use, so I'm not surprised that there is now a special keyword (well, a repurposed keyword) to address that.
Re: My Most Important C++ Aha Moments (2006)
#33Earlier quoted context omitted.
> Private-really-means-deleted was a cool and very useful trick before C++11 Rather, until every compiler you need to target supported this specific C++11 feature. In other words, it's still a cool and very useful trick ;)
This is my ignorance speaking, but with the gcc, clang, and msvc all fully supporting C++11, where are the holdups?
Re: My Most Important C++ Aha Moments (2006)
#34I love C and Objective-C. I can't stand C++. Is that common among programmers?
The more I learn C++, the more I can't stand it. Its ever-increasing complexity keeps being a distraction from the actual problem you're trying to solve.
Re: My Most Important C++ Aha Moments (2006)
#35My most important C++ Aha moment was in 1995 when I wrote my first lines of Java and realized that it was possible to write OO code without having to fight the compiler every step of the way.
Re: My Most Important C++ Aha Moments (2006)
#36> Realizing that C++’s “special” member functions may be declared private Don't do this anymore! Just delete them: MyClass& operator=(const MyClass&) = delete; Private-really-means-deleted was a cool and very useful trick before C++11. So useful, that it was a shame to require secret knowledge and aha moments to use. So they just made it a normal feature of the language. There's also a way to explicitly use the defau…
Alternative view: if you must use C++, stick to nothing later than C++2003. Anyway, declaring a constructor " = delete" isn't the same thing as making it private. If it's private, the code in your class scope can still use it. If you can't trust your class private code to do things correctly, then you're screwed; go join IT and write backup shell scripts. So basically this "= delete" is just another ear growing out o…
Re: My Most Important C++ Aha Moments (2006)
#37Re: My Most Important C++ Aha Moments (2006)
#38I love C and Objective-C. I can't stand C++. Is that common among programmers?
Re: My Most Important C++ Aha Moments (2006)
#39Earlier quoted context omitted.
Alternative view: if you must use C++, stick to nothing later than C++2003. Anyway, declaring a constructor " = delete" isn't the same thing as making it private. If it's private, the code in your class scope can still use it. If you can't trust your class private code to do things correctly, then you're screwed; go join IT and write backup shell scripts. So basically this "= delete" is just another ear growing out o…
Why?
Re: My Most Important C++ Aha Moments (2006)
#40Earlier quoted context omitted.
> Private-really-means-deleted was a cool and very useful trick before C++11 Rather, until every compiler you need to target supported this specific C++11 feature. In other words, it's still a cool and very useful trick ;)
This is my ignorance speaking, but with the gcc, clang, and msvc all fully supporting C++11, where are the holdups?