Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does C++ programmer simulate features of Java? [closed]

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.

like image 708
Jichao Avatar asked Dec 23 '09 19:12

Jichao


2 Answers

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...!)

like image 127
itowlson Avatar answered Oct 06 '22 00:10

itowlson


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

like image 20
duffymo Avatar answered Oct 06 '22 01:10

duffymo