Results 1 to 5 of 5
Hello can anyone explain about :
The diffrence between Data Abstraction and Encapsulation?
Diffrence between default Copy Constructor and default Assignment Operator Overloading in a Class?
Thanks in Advance...
- 07-07-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 21
C++ Question on Data Abstraction
Hello can anyone explain about :
The diffrence between Data Abstraction and Encapsulation?
Diffrence between default Copy Constructor and default Assignment Operator Overloading in a Class?
Thanks in Advance
- 07-07-2009 #2
I don't know the theory behind c++, just how to use it, but I'd suggest you read
Abstraction (computer science) - Wikipedia, the free encyclopedia
and
Encapsulation (computer science) - Wikipedia, the free encyclopedia
I don't know the second question's topics well enough to coment.New to the internet, technical forums, or the hacker / open source community??
Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html
RHCE for RHEL version 5
RHCT for RHEL version 4
- 07-08-2009 #3Just Joined!
- Join Date
- Jun 2009
- Location
- Toronto
- Posts
- 18
Basically a copy constructor is invoked when creating an instance based on an existing instance. Assignment involves two constructed instances.
MyClass c1;
MyClass c2(c1); <- invokes copy constructor
MyClass c3 = c1; <- also copy constructor
c2 = c1; <- invokes assignment operator
- 07-09-2009 #4Just Joined!
- Join Date
- Jun 2009
- Posts
- 3
Encapsulation is nothing but presenting essentials and hiding the implementation because in traditional prog lang like C there was no security for GLOBAL variables suppose if we declare i=10 , it 'll be accessed by any function that may be relevant or irrelevant so that to safeguard data we need encapsulation in c++
about second thing u can see in "cgrebeld" article he gave the ans
- 07-09-2009 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Overloading of default copy ctor and assignment operator.
The C++ compiler will create one of each of these automatically for any class that does not have its own. The default copy constructor will do a member-wise copy of components, doing a bit-copy of those that do not have their own copy constructor, such as scalar values, and will initialize those that do with the copied object's component. The default assignment operator will also do a member-wise copy of components, doing a bit-copy of those that do not have an assignment operator, such as scalar values, and invoke the assignment operator for those that do. This is not always what you want to happen in either case and it is STRONGLY recommended that you always implement a copy constructor and assignment operator for every class.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote