C++ promotes a separation between class definitions and class implementations but not JAVA [closed]

守給你的承諾、 提交于 2019-12-04 07:10:43

问题


I have a homework and I need to evaluate which approach is better according to GRASP.

I found this link that answers part of my questioning: Why have header files and .cpp files in C++?

However, what I want to know is how much c++ way of working is better for extensibility and for code reuse than JAVA because everything is defined in a conjoint file ?

Thanks for the help !

Edit: Just to make sure that this is not a debate, I want to know why does JAVA does not do like in C and promotes the separation between class definitions and class implementations. Are there any advantages with that way of working or proceding ?

This question was moved to https://softwareengineering.stackexchange.com/questions/118574/does-java-promote-a-separation-between-class-definitions-and-implementations-as


回答1:


the equivalent in java is that you declare class interfaces that does serve the purpose of a implementation-less declaration. The binding of the implementation to the interface does happen at runtime

in the sense of extensibility both are entirely equivalent. The differences between both languages do not lie in the extensibility capabilities themselves, but in their performance approaches. Java and C# are more uniform in their syntax and more terse, while certain C++ can be a pain to read for the beginner. C++ has extensive focus in compile-time type binding through templates, while java and C# have traditionally more focus on run-time binding and reflection. This difference has softened in the last years, although for some application domain niches (mainly high performance computing) nice language features like garbage collection are still a high barrier of entry for the likes of Java and C#



来源:https://stackoverflow.com/questions/8054058/c-promotes-a-separation-between-class-definitions-and-class-implementations-bu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!