473,473 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

copy constructors; why can access private data?

guys, I defined a copy constructor like this.

--code--
FiveTuple::FiveTuple(const FiveTuple &fv_tuple){
source_ip_ = fv_tuple.source_ip_;
dest_ip_ = fv_tuple.dest_ip_;
source_port_ = fv_tuple.source_port_;
dest_port_ = fv_tuple.dest_port_;
ip_protocol_ = fv_tuple.ip_protocol_;
}
--code--

It works.

but the source_ip_, dest_ip_, etc are all private;
How can the copy constructor access private data of fv_tuple directly?
Feb 16 '08 #1
1 1444
thomas wrote:
guys, I defined a copy constructor like this.

--code--
FiveTuple::FiveTuple(const FiveTuple &fv_tuple){
source_ip_ = fv_tuple.source_ip_;
dest_ip_ = fv_tuple.dest_ip_;
source_port_ = fv_tuple.source_port_;
dest_port_ = fv_tuple.dest_port_;
ip_protocol_ = fv_tuple.ip_protocol_;
}
--code--

It works.

but the source_ip_, dest_ip_, etc are all private;
How can the copy constructor access private data of fv_tuple directly?
Private to the type, not the object.
Feb 16 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
14
by: MSR | last post by:
I have a couple of questions. 1. Copy Constructor. class A { private: int a1; double d1; char *ptr;
2
by: John Ratliff | last post by:
What are the ramifications of creating a private copy constructor? Say I didn't want any copies to be created, say if I had a singleton for example. Should I make the copy constructor public...
10
by: utab | last post by:
Dear all, So passing and returning a class object is the time when to include the definition of the copy constructor into the class definition. But if we don't call by value or return by value, ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.