As I read in Thinking in java,
Interface and inner class provide more sophisiticated ways to organize and control the objects in your system. C++, for example, does not contain such mechanisms, although the clever programmer may simulate them.
Is it true that C++ programmer simluate features that java owns,e.g. interface and constraint themself not to step over the boundary,e.g. including non-static-final(non-const) data member within the simluated interface?
Are these features that Java provided natural way for developing software.So if C++ programmers could,they should code and think like a Java programmer?
EDIT: I know that every programming langauge have its own characteristics and its application area and the design of programming language is making tradeoffs.But what I want to know is whether something java introduced for example interface,are better way to help/force programmer think throughly and produce good class design?so C++ programmers would like to simulate some of these features?
thanks.
This is kinda subjective, but:
if C++ programmers could,they should code and think like a Java programmer?
No. They should code and think like C++ programmers. C++ has lots of idioms and techniques which do not exist in Java (and vice versa). You should use the idioms and thought patterns appropriate to the language, not try to write Java (or Pascal, or Fortran) with C++ syntax.
(That doesn't mean don't borrow tricks from other languages, of course...!)
C++ interfaces are easy: they're simply classes with all pure virtual methods, including a pure virtual default destructor. (Thanks to itowlson for the correction.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With