From: "Victor Bazarov" Newsgroups: comp.lang.c++,comp.os.msdos.djgpp Subject: Re: GENERAL DATA TYPE (Do you need one ?) Date: Tue, 20 Mar 2001 13:22:03 -0800 Organization: Advanced Telcom Group Inc. Internet Services Lines: 90 Message-ID: <998hls$sj5$1@nnrp.atgi.net> References: <9988r4$k33$1 AT tron DOT sci DOT fi> <9989to$s25$1 AT nnrp DOT atgi DOT net> <998h4d$5o0$1 AT tron DOT sci DOT fi> NNTP-Posting-Host: 64-42-102-2.atgi.net X-Trace: nnrp.atgi.net 985123324 29285 64.42.102.2 (20 Mar 2001 21:22:04 GMT) X-Complaints-To: abuse AT atgi DOT net NNTP-Posting-Date: 20 Mar 2001 21:22:04 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Traveler" wrote... > > > > > "...needs to return different kind of types..." : what for? > Only one answer: > Heterogenic doubly-linked list A doubly-linked list of anything? Why? It doesn't make any sense to have everything as a potential member of the list. > > > > > > Example: > > > > > > Object f(void); // Function overloading is not possible if only > > the > > > return value changes > > > // int f(void), short f(void), etc... are > > not > > > possible > > > > Yes. So? > Look above... Looking... Not seeing anything. > > > > > > > > // The following would be possible... > > > int x = f(); > > > long y = f(); > > > > What would that do? > It depends.... > What would you like it to do ??? Precisely. When I need some functionality, I put it there. And in most cases the way it is implemented and _named_ must make some sense for those who read the code. > (I certainly know what the "Object& getNode(DWORD index)" will do !!! :=)) I don't. What would it do? Is that a global function? the 'getNode' method of class List should return the type of the List's element. But as I stated above, I don't see any sense of having a generic "list of anything". > > > > > // So would this... > > > int x = 10; > > > int y = 20; > > > Object tmp; > > > tmp = x; > > > x = y; > > > y = tmp; // Now, x has 20 & y has 10 > > > > Why can't 'tml' be 'int'? > That was just an example.... Bad example, as it turns out. > Point is it works and it can handle ALL the basic data types Again, what for? The whole idea of type-specific programming is to make object distinguishable not only by their name (address) but by their type as well. You failed to provide any reasonable need for the "base of everything" type. > > You can also use it on those of your own work. But why? I will use the type I need, not a generic one. > > The only catch is that A) you have to use inheritance & B) you have to > define conversion function that returns some value from your object There is no need. A generic "replacement for everything" object will be _unable_ to do anything -- it simply will not be able to have _any_ functionality. Besides, we already have a type for that. It's called "pointer to void". Victor -- Please remove capital A's from my address when replying by mail