COPY CONSTRUCTOR IN C++ ( 33)

Sdílet
Vložit
  • čas přidán 15. 02. 2017
  • COPY CONSTRUCTOR IN C++
    The copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously. The copy constructor is used to:
    Initialize one object from another of the same type.
    Copy an object to pass it as an argument to a function.
    Copy an object to return it from a function.
    If a copy constructor is not defined in a class, the compiler itself defines one.If the class has pointer variables and has some dynamic memory allocations, then it is a must to have a copy constructor.
    Mail: aniproguy@gmail.com
    Music:BACK IN SUMMER by Nicolai Heidlas Music / nicolai-heidlas
    Creative Commons - Attribution 3.0 Unported- CC BY 3.0
    creativecommons.org/licenses/b...
    Music provided by Audio Library • Video
    ------------------------------------------------------------------------------------------------
    Suggested Videos
    Function Overloading (FUNCTION IN C++ - PART 4) :- • Function Overloading (...
    Void or Generic Pointer in c++ :- • Void or Generic Pointe...
    Variables and Data Types in C++ :- • Variables and Data Typ...
    Data Type Range in C++ :- • Data Type Range in C++...
    Comments in C++:- • Comments in C++ -7
    Inline Function - FUNCTION IN C++ (PART - 3) :- • Inline Function - FUNC...
    Function Overloading (FUNCTION IN C++ - PART 4)
    • Function Overloading (...
    Class and Objects(part-3)[VISIBILITY MODES IN C++] :- • Class and Objects(part...
    Class and Objects[Most Important Video] Part-5 (Complex Number Program)
    • Class and Objects[Most...
    STATIC FUNCTIONS IN C++ :- • STATIC FUNCTIONS IN C+...
    CONSTRUCTOR IN C++ ( SYNTAX AND PROGRAM AND ALL POSSIBLE ERRORS)
    • CONSTRUCTOR IN C++ ( S...
    STATIC VARIABLE OR STATIC DATA MEMBER IN C++ :- • STATIC VARIABLE OR STA...
    Constructor Overloading in C++- 32 :- • Constructor Overloadin...

Komentáře • 118

  • @Codearchery
    @Codearchery  Před 5 lety +56

    Hey Guys,
    I have made a mistake at 2:35
    There are only two forms of calling copy constructor.
    ------------------------------
    example obj1(50);
    example obj2;
    obj2 = obj1;
    This is not invoking the Copy Constructor.
    ------------------------------
    Here assignment operator(=) is overloaded by default by the Compiler.
    I am truly sorry Guys, it won't happen again.
    ----------------------------------------------------------------
    Special Thanks to Mayuri Popat for pointing out my Mistake.

  • @Harsimran_Singh_27
    @Harsimran_Singh_27 Před 6 lety +57

    There are many C++ programming tutorials on CZcams but to understand most of them, you really need to be very attentive and after watching one or two of those videos, you get saturated and feel unable to move further. You are unable to watch more than 3-4 videos at a stretch - but these tutorials are so beautiful. These are so simple, easy on the mind and effective. This is a revolutionary channel. Brilliant work... Keep uploading more videos to help Computer Science students and to make it easier for us to earn our degrees !!!

    • @Codearchery
      @Codearchery  Před 6 lety +8

      Thank u so much Harsimran . I think , I achieved my Goal.
      Thanks a lot for this comment and I will keep on uploading more good stuff
      Don't forget to share and
      Keep on watching and keep on learning

  • @cautioni
    @cautioni Před 5 lety +8

    Don't stop. Keep uploading, understanding programming has never been this fun and easy.

  • @annonymousfox7515
    @annonymousfox7515 Před 6 lety +2

    These are the best videos on C++ I've seen on youTube!! You are amazing and thank you so much for creating this! I hope these videos make you rich cuz you deserve it! Keep it up!

    • @Codearchery
      @Codearchery  Před 6 lety +1

      Thanks AnonymousFox
      Have you seen Codearchery.com teaser?
      czcams.com/video/cqLdlBaohLU/video.html
      Did you like it ?

  • @manishkumar1450
    @manishkumar1450 Před 5 lety

    crisp and clear approach of teaching.

  • @kirthikas1896
    @kirthikas1896 Před 3 lety

    Truly by watching your video alone I'm going to attend my sem, with lot more confidence! Never ever stop doing this :) you are tooo great !

  • @theanger5930
    @theanger5930 Před 5 lety +1

    Despite the mistake you made, this video is just on point. You explained everything so well, thank you.

  • @mugiifeed6156
    @mugiifeed6156 Před 3 lety

    Love and respect from Sri Lanka,This is the Great Video series on C++

  • @shaikhtanzil2630
    @shaikhtanzil2630 Před 5 lety +2

    plz never stop making videos like this

  • @supersaiyanlimitbreaker3018

    Very well presented. easy to understand.

  • @rhitikkrishnani510
    @rhitikkrishnani510 Před 3 lety +2

    I am preparing for my placements. These lectures are really helpful. Thank you sir !!

  • @imadbouchallikh7296
    @imadbouchallikh7296 Před 4 lety

    when we try to copy any constructor manually we are doing a kind of copy that allows us to access to the current copied constructor's attributes, which means we can change a particular attribute values as well us keeping them as they are. thanks Codearchery for this awesome explanation.

  • @areegahmed3926
    @areegahmed3926 Před rokem

    LITERALLY THE BESTTTT!!!!!!!!!

  • @exoticme4760
    @exoticme4760 Před 6 lety

    as always SUPERB !

  • @helios9595
    @helios9595 Před 9 měsíci

    For The First Time in my life I enjoyed and very interested watch lectures.
    just keep going on dont change your style.

  • @michaelvela2835
    @michaelvela2835 Před 3 lety

    Great video!

  • @xxkingcoreyxx5499
    @xxkingcoreyxx5499 Před 6 lety

    yoooo nice job,good work man please carry on

  • @IslamIslam-hd1ow
    @IslamIslam-hd1ow Před rokem

    That's really helped me thank you

  • @Pishkoo
    @Pishkoo Před 3 lety

    Just wow...Superbly awesome 🥰

  • @shivanigoswami2773
    @shivanigoswami2773 Před 3 lety

    Really I was enjoying it
    Fully satisfied for this concept in this way thank you

  • @ariyanpritom9071
    @ariyanpritom9071 Před rokem

    Yes Bro. Your video deserves LIKE.

  • @triggermanrd3448
    @triggermanrd3448 Před 5 lety

    Saw many videos but never see this type of video Amazing

  • @rushdaquraishi2206
    @rushdaquraishi2206 Před 6 lety

    Really awesome way to teach using animation. I love it keep updating

  • @abrahamyalley9973
    @abrahamyalley9973 Před 3 lety

    BEAUTIFUL!!

  • @r_m5545
    @r_m5545 Před 3 lety

    Thanks a lot man

  • @ganeshbhavana1061
    @ganeshbhavana1061 Před 4 lety

    I appreciate u r work

  • @sanketsharma7141
    @sanketsharma7141 Před 5 lety

    So amazing.... Superb....Kya CZcamsr h yr....

  • @QuickTale55
    @QuickTale55 Před 4 lety

    Tks for a good video

  • @rashidakhatun7437
    @rashidakhatun7437 Před 6 lety +3

    Thanks a lot

  • @shivanigoswami2773
    @shivanigoswami2773 Před 4 lety

    Difference way unique explanation...
    Can easily understand all concept within 4 to 5 min only.thats a great video smart work I like.it👌👌👌👌

  • @joeydicastro
    @joeydicastro Před 6 lety

    Very good video and so funny, btw it is always a good practice to set copy constructor params as const reference :)

  • @usama57926
    @usama57926 Před 5 lety +2

    u r great explanier

  • @esabkhan7901
    @esabkhan7901 Před 4 lety

    You Know ,how to make people understand something , better than many.

  • @suhaibkorg
    @suhaibkorg Před 3 měsíci

    thanks a lot

  • @mohammadawaisrana8878
    @mohammadawaisrana8878 Před 3 lety

    Very nice teaching method😍

  • @usama57926
    @usama57926 Před 5 lety +1

    thank u very much

  • @aafreengundigara8898
    @aafreengundigara8898 Před 5 lety

    Perfect explain👍

  • @user-ro7ik3tt8v
    @user-ro7ik3tt8v Před 4 lety

    Very good

  • @amerbangla7256
    @amerbangla7256 Před 5 lety

    great job dear just outstanding tutorials

  • @vellyjatt7824
    @vellyjatt7824 Před 6 lety

    Nice work

  • @Arnob127
    @Arnob127 Před 4 lety

    Epic!

  • @ahmedalaa9214
    @ahmedalaa9214 Před rokem

    I hope all the best for you ❤️

  • @joshuatejero5617
    @joshuatejero5617 Před 3 lety

    Ya deserve a like!!

  • @keepitsimplesonu
    @keepitsimplesonu Před 2 lety

    Methodology 🙌🏻❤

  • @MASBHANOMAN
    @MASBHANOMAN Před 7 lety +4

    really appreciated
    good work...

    • @Codearchery
      @Codearchery  Před 7 lety +1

      Thanks Masbha for watching my videos :-)
      I hope you'll love to help me by sharing My Channel with Your Friends
      Keep on Watching and Keep on Learning

    • @Singikulam
      @Singikulam Před 5 lety

      C

  • @dhrinsagrawal9057
    @dhrinsagrawal9057 Před 6 měsíci

    Thanks

  • @yunaimenodacid5828
    @yunaimenodacid5828 Před 6 lety

    Hi, when you write exmaple ob1(50); example obj2; are calling parameterise and default constructor. When you write obj2 = obj1; them is calling assigment operator. I think. Great videos.

  • @RahulKumar-tf8uq
    @RahulKumar-tf8uq Před 7 lety +2

    good concept.. i like the way you teach

    • @Codearchery
      @Codearchery  Před 7 lety +1

      Thanks a lot Rahul , I hope you'll love to share this channel with your friends too .
      Keep on Watching and learning :-)

  • @teen_shine_6239
    @teen_shine_6239 Před 6 lety

    Best

  • @samaryadav7208
    @samaryadav7208 Před 6 lety +6

    @2:34 is assignment operator NOT copy constructor. Else it is a great video.

    • @JeesJoy
      @JeesJoy Před 6 lety

      Samar Yadav it is a copy constructor

  • @junaidsatti5012
    @junaidsatti5012 Před 6 lety +1

    Thank Good Video

    • @Codearchery
      @Codearchery  Před 6 lety

      Thanks Junaid for Watching my Videos
      I hope you would like to help me by Sharing My Channel with your Friends
      Keep on Watching and Keep on Learning

  • @vanshikaanand3969
    @vanshikaanand3969 Před 6 lety +4

    isn't the second way of calling copy constructor '=' operator overloading??!

  • @poojasalvi1262
    @poojasalvi1262 Před 3 lety

    How I practice c++ programming to clear each concepts and also how to improve logic pls tell me sir your videos are really help me to learn c++ keep making videos.....🙏👍

  • @vaishnavijha5742
    @vaishnavijha5742 Před 5 lety

    why have you written & symbol in the argument list of copy constructor? explain please.

  • @Haxr-dq6wt
    @Haxr-dq6wt Před 6 lety +1

    my brother you are the best instructor on youtube
    i want to be your friend on facebook

  • @saurabhs4743
    @saurabhs4743 Před 6 lety

    Why does the default contructor have access specifier?

  • @divyasammeta4383
    @divyasammeta4383 Před 6 lety

    Can u give brief on non parameterised with syntax and program

  • @prathamsharma6368
    @prathamsharma6368 Před 6 lety +1

    very good

    • @Codearchery
      @Codearchery  Před 6 lety

      Thanks Pratham
      Plz Share My Videos with your friends

  • @ramachandraudupi6641
    @ramachandraudupi6641 Před 5 lety +1

    But sir,"data" is private member data,i understand dummy is a reference to obj1 in this example I don't have a doubt in that,but how could you use dummy.data in copy constructor???can someone help please!!!!!!

  • @theradhikagupta
    @theradhikagupta Před 5 lety

    Please make videos of c++ 11 and c++14 concepts

  • @JeesJoy
    @JeesJoy Před 6 lety +3

    Very useful!.keep making videos like this😍

  • @tanveerasif5978
    @tanveerasif5978 Před 6 lety +2

    you didn't explain:-
    1- Shallow copy n deep copy
    2- Copy constructor parameter : why const specifier n pass by reference

  • @shoaibkhairmuhammad9695

    Why we use two variables x and data.. One is for copying other value?

  • @user-oe5jp3xq3z
    @user-oe5jp3xq3z Před rokem

    but what is the use '&' in copy operator???

  • @mohansrikri
    @mohansrikri Před 7 lety +1

    Can you explain shallow copy and deep copy concepts...

    • @Codearchery
      @Codearchery  Před 7 lety +1

      Yeah why not , I will be uploading the videos in upcoming few days

  • @paridhimodi2450
    @paridhimodi2450 Před 6 lety +2

    i never get what my teacher teaches in skul.
    but aftr watching your videos i understood everything written in book

    • @Codearchery
      @Codearchery  Před 6 lety +1

      Wow....... I am happy that My Channel is so much Useful
      Hey Parishi Share My Channel with Your Teacher :-P So that your teacher can teach the fun in Programming to students

    • @paridhimodi2450
      @paridhimodi2450 Před 6 lety +2

      hahaha for sure

    • @paridhimodi2450
      @paridhimodi2450 Před 6 lety +2

      never mind

    • @paridhimodi2450
      @paridhimodi2450 Před 6 lety +2

      can you pls upload videos of pointers

  • @Shubham-xh9nz
    @Shubham-xh9nz Před 6 lety +1

    3:06 whats that example ( example & data){
    data = dummy.data
    }
    is syntax of copy constructer ? Or something else

    • @Codearchery
      @Codearchery  Před 6 lety +3

      You got it right , this one is the syntax of copy constructor

  • @poojasalvi1262
    @poojasalvi1262 Před 3 lety

    How to practice c++ programming to clear each & every concepts & also how to develop logic pls tell me sir.....🙏👍

  • @Vishakitha
    @Vishakitha Před rokem

    Why some programs in use int main() then some programs in use void main() if I wrote the program how I choose main() bro

  • @nawalkishoresingh4794
    @nawalkishoresingh4794 Před 5 lety

    Nice video.
    But copy constructor manually is not clear to me.
    Any video reference for understanding copy constructor manually , for clearing our concept

  • @GurpreetSingh-qx4if
    @GurpreetSingh-qx4if Před 2 měsíci

    Sir pls make video on type conversion -basic to class, class to basic or class to class.

  • @anshkevadiya8731
    @anshkevadiya8731 Před 3 lety +1

    can you make this type of video for java , phyton and javascript actually i enjoyed learning like this hope you wll reply soon thank you team codearchery thanks a lot

  • @dude5697
    @dude5697 Před 5 lety

    What does end1 mean?

  • @usama57926
    @usama57926 Před 5 lety +6

    bro which software u use for making these videos

  • @kavinashokan5692
    @kavinashokan5692 Před 5 lety

    Uses of copy constructors?

  • @vellyjatt7824
    @vellyjatt7824 Před 6 lety

    From which country you are?

  • @anyk.3741
    @anyk.3741 Před 7 lety +1

    I'm confused . Example obj2; obj2 =obj 1 ; how does this involves copy constructor as object is not copyed at construction.

    • @samaryadav7208
      @samaryadav7208 Před 6 lety

      it's not. He made a mistake. It is actually assignment operator.

    • @sarveshkaran9380
      @sarveshkaran9380 Před 5 lety

      right its assignment operator call,not copy constructor

  • @mohitweekendvlogs
    @mohitweekendvlogs Před 6 lety +3

    One day this channel have millions of subscribers .

  • @deepakborah8335
    @deepakborah8335 Před 7 lety

    Sir As compiler will make a copy constructor if we don't make. In actual argument we are passing obj2 of example type as, example obj1(obj2).It means we are passing value of example type of obj2.. Why we need to put reference operator at formal argument inside the parentheses eg. example ( example &dummy) to copy obj1 to obj2 ? Here dummy is nothing but obj2 .Without reference operator it gives error.The content will be copied to obj1 no doubt. Why reference operator is compulsory. Is there any other way to copy without & operator.?

  • @douchelick7263
    @douchelick7263 Před 5 lety

  • @jattsuryanshchoudhary6927

    sir small doubt in copy constructor defining... data=dummy.data
    this line is not properly clear

    • @Codearchery
      @Codearchery  Před 7 lety +4

      look we are copying data manually
      so we are representing dummy as object.
      the variable data belongs to the newly created object.
      And dummy.data means data variable which is present in the object dummy.
      Okay You might get confused with all of this , Keep on Watching further videos and Keep on Practicing
      You will understand what this line means when you practice a lot:-)

    • @cyborgdale
      @cyborgdale Před 6 lety +2

      Suryansh Choudhary The copy constructor is a function and therefore behaves like other functions. Here the object, obj1, is passed-by-reference so it is automatically dereferenced just by saying "dummy.data" (instead of "(*dummy).data" or "dummy->data".) The calling object is obj2 so "data" needs no "object_name..." in front of it. (Remember, as far as the written code goes, the only difference between passed-by-reference and pass-by-value is the & in the parameter list. Everything else in the text is the same.) Does that help?

  • @jattsuryanshchoudhary6927

    Sir mje book 📖 S bilkul smj ni aaaa ra ta... you helped me alot

    • @Codearchery
      @Codearchery  Před 7 lety +1

      Do this for every Concept.
      First Watch my Video and then read the book :-)
      And you will understand everything

  • @Ms_Priya26
    @Ms_Priya26 Před 4 lety

    But in this prgm u didn't creat object for default constructor?
    Other two objects carry parameters... Then how it'll run default constructor.... But ur prgm has executed!!!! 🤷🏼‍♀️ Help me to clear this doubt

  • @eyupcan1831
    @eyupcan1831 Před 6 lety

    If we can make a copy constructor automatically, why do we need manuel?

    • @chinmaykulkarni2897
      @chinmaykulkarni2897 Před 6 lety

      Eyüp Can Turgut for good programming practice

    • @Codearchery
      @Codearchery  Před 6 lety

      Have you seen Codearchery.com teaser?
      czcams.com/video/cqLdlBaohLU/video.html
      Did you like it ?

    • @Codearchery
      @Codearchery  Před 6 lety

      Thanks Chinmay for replying to Eyup

  • @giriminati
    @giriminati Před 7 lety +1

    bro ..only this sub teahing like this or other sub also have in this animated way...........if u know........... link me........plz........

    • @Codearchery
      @Codearchery  Před 7 lety +1

      Hi Girish,
      Currently I am uploading videos of C++ and Data Structure only.
      But In future I'll try to put every subject on CZcams :-)
      By the way I like John Cena too :-)

    • @giriminati
      @giriminati Před 7 lety +2

      yeah.......me2.....keep teaching like this way............tqu

  • @samiulislamdurjoy
    @samiulislamdurjoy Před 3 lety

    G 5

  • @kri7teen
    @kri7teen Před 2 lety

    Good explanation, but so annoying audio

  • @lokeshthakre9500
    @lokeshthakre9500 Před 6 lety

    data=-50 ,how?

  • @emrebilgis
    @emrebilgis Před 2 lety

    puhsadasdhahaha bu kadar kolay mıydı