Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: ittium Newsgroups: comp.lang.c++ Subject: Re: wrapper class and N-to-1-uses-a relationship Date: Sun, 25 Dec 2011 10:33:42 +0530 Organization: A noiseless patient Spider Lines: 43 Message-ID: <4EF6AEAE.1010300@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="uqsYOzqBuj2VafXCFKKNNw"; logging-data="28541"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19oQKUjjtbbl5fZsVk/b7ID" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: Cancel-Lock: sha1:GpQzdjn5G3zHS4LEt93ig6nHSdo= Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:12804 On 24-12-2011 PM 09:16, Paavo Helde wrote: > Victor Bazarov wrote in > news:jd4lt5$knq$2@dont-email.me: > >> On 12/24/2011 4:58 AM, Paavo Helde wrote: >>> ittium wrote in news:jd25dr$6b6$1@dont-email.me: >>> >>>> Group, >>>> I have a small doubt regarding >>>> http://www.parashift.com/c++-faq-lite/value-vs-ref-semantics.html#faq >>>> -3 1.4 As per this faq, only valid places(apart from virtual/dynamic >>>> data) to use reference semantic are >>>> - wrapper class >>>> -N-to-1-uses-a relationship >>>> These are generic terms, will appreciate if some one could explain >>>> or probably direct me to some link. Google search did not offer >>>> much. > [...] >>> With the wrapper classes it is not so clear what the author has >>> meant. I guess in this context this just means that the A object is >>> already existing and must remain accessible from other parts of the >>> program as the A object. Maybe it is a member in some std::map or >>> other container. However, other parts of the program want to have >>> access to the exact same object, but via different interface. As it >>> might not be possible or feasible to add this interface directly to >>> the A class, a wrapper class B is defined instead, which provides the >>> needed interface and forwards the actual function calls to the >>> original A object. For doing this it must contain a pointer or >>> reference to the A object. >> >> I believe a more appropriate term for the latter is "adapter" instead >> of "wrapper". Wrappers *usually* contain the object they "wrap". > > Yes, "adaptor" would be more appropriate. Nevertheless, from this FAQ > section I get a feeling that by "wrapper" they mean just a "class wrapping > a pointer or reference to an object of another class". But then it seems > very close to to a tautology to claim that this requires storing a pointer > or reference. > > Cheers > Paavo > Copying it to Marshall Cline, He might like to add something.