digitalmars.D - Forward Declaration
- Satish (31/31) Mar 15 2007 Hello D Programmers
- Derek Parnell (50/85) Mar 15 2007 What is the difference between ...
- Henning Hasemann (8/8) Mar 15 2007 There are .di-files which just hold the information about a class
- BCS (6/15) Mar 17 2007 IIRC it is for the same reason that D doesn't have prototypes and hand m...
Hello D Programmers As a C++ programmer I have written classes such as class Object{ public: Object(int value1); }; Object::Object(int value1){} My terminology will be wrong here but I really enjoy separating the declaration and implementation of class members. Yes in C++ also allows such declaration: class Object{ public: Object(int value1){return 100;} long server(){ //several lines of code 1 //several lines of code 2 //several lines of code 3 //several lines of code 4 } }; Why doesn't 'D' allow to separate method definition and method implementation such as < Object::Object(int value1){ //my implementation }If becomes tough not hard to debug classes if/when there is closing curly bracket if it missing. I seem to more time ensure that I don't miss any opening and closing braces. Thanks for the advice. Satish
Mar 15 2007
On Fri, 16 Mar 2007 03:37:07 +0000 (UTC), Satish wrote:Hello D Programmers As a C++ programmer I have written classes such as class Object{ public: Object(int value1); }; Object::Object(int value1){} My terminology will be wrong here but I really enjoy separating the declaration and implementation of class members.Why?Yes in C++ also allows such declaration: class Object{ public: Object(int value1){return 100;} long server(){ //several lines of code 1 //several lines of code 2 //several lines of code 3 //several lines of code 4 } };What is the difference between ... class Object{ public: Object(int value1){return 100;} long server(){ //several lines of code 1 //several lines of code 2 //several lines of code 3 //several lines of code 4 } }; and class Object{ public: Object(int value1); long server(); }; Object::Object(int value1){return 100;} long Object::server(){ //several lines of code 1 //several lines of code 2 //several lines of code 3 //several lines of code 4 }Why doesn't 'D' allow to separate method definition and method implementation such as < Object::Object(int value1){ //my implementation }Actually it does allow that style of coding ... // define (list) the methods to be implemented. interface XXX { long server(); } // now implement them. class OBJect : XXX { long server() { //several lines of code 1 //several lines of code 2 //several lines of code 3 //several lines of code 4 } }If becomes tough not hard to debug classes if/when there is closing curly bracket if it missing. I seem to more time ensure that I don't miss any opening and closing braces.Both styles have the same brace matching issue so I don't see why you might think this is a problem with the D style. -- Derek (skype: derek.j.parnell) Melbourne, Australia "Justice for David Hicks!" 16/03/2007 3:29:56 PM
Mar 15 2007
There are .di-files which just hold the information about a class (in fact the whole module) thats needed to *use* it, IIRC. These look similar to header files in C++ and serve a similar purpose so it seems to me, so maybe they are some help to you, getting an overview over your classes or whatever. Henning -- v4sw7Yhw4ln0pr7Ock2/3ma7uLw5Xm0l6/7DGKi2e6t6ELNSTVXb7AHIMOen5a2Xs5Mr2g5ACPR hackerkey.com
Mar 15 2007
Reply to Satish,Hello D Programmers[...]Why doesn't 'D' allow to separate method definition and method implementationIIRC it is for the same reason that D doesn't have prototypes and hand made headers (.di's are generated by DMD). The issue is that having duplicate information can cause problems if only one is updated. [...]Thanks for the advice. Satish
Mar 17 2007