Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
public or private inheritance of boost::noncopyable?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
lbonaf...@yahoo.com  
View profile  
 More options Mar 27 2008, 10:51 am
Newsgroups: comp.lang.c++
From: lbonaf...@yahoo.com
Date: Thu, 27 Mar 2008 07:51:16 -0700 (PDT)
Local: Thurs, Mar 27 2008 10:51 am
Subject: public or private inheritance of boost::noncopyable?
Every example I see (including on boost::org) of using noncopyable
involves inheriting from it privately.   Is there a drawback from
inheriting publicly?   Is it just that it's not a good example of and
"is-a" relationship?

#include <boost/utility.hpp>

class A : public boost::noncopyable {};

int main()
{
        A a;

        A b(a);

        return 0;

}

g++ -Wall -I\boost_1_33_1 -c noncopy.cpp

noncopy.cpp: In copy constructor `A::A(const A&)':
/boost_1_33_1/boost/noncopyable.hpp:27: error:
`boost::noncopyable_::noncopyable
::noncopyable(const boost::noncopyable_::noncopyable&)' is private
noncopy.cpp:9: error: within this context


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alan Johnson  
View profile  
 More options Mar 27 2008, 11:57 am
Newsgroups: comp.lang.c++
From: Alan Johnson <aw...@yahoo.com>
Date: Thu, 27 Mar 2008 08:57:12 -0700
Local: Thurs, Mar 27 2008 11:57 am
Subject: Re: public or private inheritance of boost::noncopyable?

lbonaf...@yahoo.com wrote:
> Every example I see (including on boost::org) of using noncopyable
> involves inheriting from it privately.   Is there a drawback from
> inheriting publicly?   Is it just that it's not a good example of and
> "is-a" relationship?

You've pretty much answered the question already.  You don't want people
making a function like:

void profoundlyUselessFunction(const boost::noncopyable &);

The typical use of boost::noncopyable is a "implemented in terms of"
relationship, which is best modeled by inheriting privately.

 From a technical standpoint, since everything interesting in
boost::noncopyable is private already, whether you inherit publicly or
privately makes very little difference.

--
Alan Johnson


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alexander Dong Back Kim  
View profile  
 More options Mar 28 2008, 2:28 am
Newsgroups: comp.lang.c++
From: Alexander Dong Back Kim <alexdb...@gmail.com>
Date: Thu, 27 Mar 2008 23:28:02 -0700 (PDT)
Local: Fri, Mar 28 2008 2:28 am
Subject: Re: public or private inheritance of boost::noncopyable?
On Mar 28, 1:57 am, Alan Johnson <aw...@yahoo.com> wrote:

That was a great answer =)

cheers,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »