Live data from Hacker News

My Most Important C++ Aha Moments (2006)

artima.com

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…

Interesting, I didn't know about `delete`.

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)

#33

Earlier 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?

There are people which, for reasons good and bad, use very old versions of their tools. There are also C++ compilers other than gcc, clang and msvc.

Re: My Most Important C++ Aha Moments (2006)

#34
post #10
post #3

I 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.

But the same can be said about mathematics, for example. While true, such statement is only saying something about the process of learning; it does not mean that C++ (or mathematics) is badly designed, useless, or is not worth learning. When you are just learning, of course you tend to be more focused on the subtleties of the subject itself rather than on its applications. Which is not to say that it is a good idea: it is through application that you begin to understand and fully appreciate the subject.

Re: My Most Important C++ Aha Moments (2006)

#35

My 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.

Does this reflect your view regarding development in C++ and Java and is your comment merely a lazy reflection of that?

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…

Why?

Re: My Most Important C++ Aha Moments (2006)

#37
post #5

Yep the beauty (and maybe curse) of C++ iterators is that they are a faithful abstraction of pointers.

some people would argue that pointers themselves are a type of iterator

I would argu those people are terribly wrong, as pointers serve more purposes than iteration

Re: My Most Important C++ Aha Moments (2006)

#38
post #3

I love C and Objective-C. I can't stand C++. Is that common among programmers?

Have you tried modern C++ (that is, C++11 and C++14)? It has a very different feel these days. I used to prefer C as well, but C++ has come a long way in ease of usability.

Re: My Most Important C++ Aha Moments (2006)

#39

Earlier 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?

[deleted]

Re: My Most Important C++ Aha Moments (2006)

#40

Earlier 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?

Icc
Post reply on HN