Are synthesized copy control members always public?

时间:2015-07-29 00:11:30

标签: c++ c++11

When we don't define any constructors, the compiler synthesizes a default constructor for us. And the compiler will always synthesize the copy constructor, copy assignment and destructor if we don't define them ourselves. I want to know if the synthesized copy control members are always public? Or is there any way to control the access of these synthesized members?

Edit: To clarify, I want to know what the default access are for these members if I don't declare them at all.

3 个答案:

答案 0 :(得分:3)

Yes, you can get the synthesized special functions, but with different access controls:

tmpData$colorname <- rep(c('red','blue','blue'),2)

ggplot(tmpData, aes(x=x, y=y)) + 
  geom_dotplot(binaxis = "y", stackdir = "center", dotsize=4, fill=tmpData$colorname)

Since it's still declared private, it's not public, but you don't need to define it.

答案 1 :(得分:2)

They should be public

http://en.cppreference.com/w/cpp/language/copy_constructor

If no user-defined copy constructors are provided for a class type (struct, class, or union), the compiler will always declare a copy constructor as a non-explicit inline public member of its class

答案 2 :(得分:-1)

The old way of blocking these member functions from being available for use was to declare them private yourself. Now you can just set the member functions equal to <link rel="import" href="../bower_components/firebase-elelment/firebase-auth.html"> :

delete