3 ms·
The only thing I dislike about C++ is that I can't declare private fields privately, I can use private: but it is there in header... in C I can just declare str
by netdur 6y ago
The only thing I dislike about C++ is that I can't declare private fields privately, I can use private: but it is there in header... in C I can just declare struct Foo; in header then implement it without expose its gusts.
- gpderetta 6y agoWhat do you mean? You can do exactly the same thing in C++. You can't instantiate a value of that type [1] as it requires knowing the size, but, via base classes and pointers you can still call functions on it. [1] but see the letter/envelope idiom.
- LeifCarrotson 6y agoIs that a security concern, an obscurity concern, or a readability concern?
- netdur 6y agousability, say I use external library Bar, then I declare private: Bar bar; the end use will have install Bar library as well to use my library despise Bar being embedded in my static library, I dislike that.
- maxlybbert 6y agoAre you familiar with the PIMPL idiom?
- netdur 6y agovery nice, I do that but never header of PIMPL
- maxlybbert 6y agoI wouldn’t use PIMPL unless you get something out of it (and “not letting anybody see the private stuff” counts as getting something). It’s a hassle, but it’s also the standard answer to the problem.