Copy Constructor in C++ | C++ Tutorials for Beginners #34

Поделиться
HTML-код
  • Опубликовано: 17 окт 2024

Комментарии • 605

  • @parth8746
    @parth8746 3 года назад +124

    These tutorials are meethi davai for us

    • @Noname-zt7ii
      @Noname-zt7ii Год назад +2

      Why ??🤔

    • @RohitSingh-vy2ff
      @RohitSingh-vy2ff Год назад

      Us nhi, me bol..........meethe logo ko har chiz meethi lagti he🤣🤣🤣🤣
      Tiktoker lag rha he, sala meetha launda

    • @portbiar3678
      @portbiar3678 11 месяцев назад +4

      Because he is meetha

    • @buriburizaemon1711
      @buriburizaemon1711 8 месяцев назад

      @@portbiar3678hahahahahhahahahahahah

  • @rajaryan4647
    @rajaryan4647 3 года назад +35

    Harry sir please make a playlist on coding questions which is asked in interview( company to company).

  • @gururaj2199
    @gururaj2199 4 года назад +14

    Since I have been answering many people's questions in your comments you should give my idea a go sir

  • @shujakhaleel8993
    @shujakhaleel8993 3 года назад +81

    9:33: z1 ka value x ke barabar aayega jo ki 0 hai.
    12:40: for z2 = z, copy constructor will not be invoked.
    13:28: for Number z3 = z, copy constructor will be invoked.

  • @dhruvmalik8052
    @dhruvmalik8052 3 месяца назад +2

    I love how precise the explanations are and the way you teach.

  • @_shultz3675
    @_shultz3675 3 года назад +3

    Bhaiya , aap bahut acha padhate hain , sab kuch samjh aata hai .
    Mza aaa gaya

  • @_CSA_KRISHNAKANT
    @_CSA_KRISHNAKANT 3 года назад +11

    9:42 there will be no error as we predefined x as Number(3) so it stores the value of Number(3) so that value passed through that object..
    :)

  • @shivamchansoriya4460
    @shivamchansoriya4460 2 года назад +9

    Thank you so much Harry bhaiya❤, for providing such a great knowlegde in so easy to understand way !!

  • @The_Right_One1
    @The_Right_One1 Год назад +3

    1. Number Z1(x) is copied using "shallow copy constructor", which means that Z1 and x share the same memory location.
    2. Number Z1 = x; is copied using "deep copying constructor", which means that Z1 and x are independent, and changes made to one will not affect the other.

    • @apaarmeetsingh3527
      @apaarmeetsingh3527 9 месяцев назад

      thx bro😀 was looking for this concept only and you made me clear with two lines of comment only

  • @TheISP
    @TheISP 4 года назад +44

    Thank you so much Harry Bhai! I have been learning a lot daily! And the examples used are extremely understandable. Thank you for taking the effort

    • @TheISP
      @TheISP 3 года назад

      @HAMZA khan this is a constructor that takes another object as argument, and assigns value of referenced object variables to the newly created object

    • @TheISP
      @TheISP 3 года назад

      @HAMZA khan ds and algo is always nice

  • @animeshmaji9515
    @animeshmaji9515 4 года назад +1

    Bro app code runner k settings pe ja kar 'save and run' wala option check karlo tab apko bar bar error nahi milega jo naa save karne par milta hain.....

  • @mohammedwaseem8599
    @mohammedwaseem8599 3 года назад +34

    Your teaching style is awesome the examples you give is excellent

  • @ManishSingh-zh8jz
    @ManishSingh-zh8jz 3 года назад +14

    1M new subscribers in one year. Tremendous growth Harry bhai ! 😮

  • @rahuljonas1531
    @rahuljonas1531 Год назад +1

    Hello Harry bhai.....! How are you?
    In this video, the classes you are creating are underlined.
    Kindly tell me that how you underlined the specific text in VS Code???
    Anxiously waiting for your reply. Thank you.

  • @virtualf5317
    @virtualf5317 Год назад +1

    what is the difference between a copy constructor and constant copy constructor.
    i.e. 1.) copy (const copy &obj)
    2.) copy(copy &obj)

  • @067_subharajmishra8
    @067_subharajmishra8 3 года назад +2

    you are a great mentor harry sir btw Ide kaise sundar kare

  • @technovchannel8498
    @technovchannel8498 3 года назад +2

    Wowww कितना अच्छेसे explain किया आपणे हॅरी भाई😍😍🔥🔥

  • @prashantmajumdar1519
    @prashantmajumdar1519 4 года назад +1

    Harry bhai please please please make a video on how to learn programming or how to learn a language completely and from which resources and also how you learned programming and when you started learning it and from where you learned so well and how you developed your interest in programming please Harry bhai make a video on it because many of us wants to know more about these things

    • @engineerbhai7642
      @engineerbhai7642 4 года назад

      He did B. Tech and M. Tech dual degree from l. I T kharagpur with silver medal and best student award winner.

  • @Asish0089
    @Asish0089 11 месяцев назад +6

    10:35 default copy constructor, without any copy constructor even if we call copy constructor there is no error
    Imp consp 12:52
    Consp 13:26

  • @mahigour7124
    @mahigour7124 Год назад +1

    Thank you so much for such a great knowledge.

  • @atharvpatharkar1652
    @atharvpatharkar1652 3 года назад +3

    Thank You 🙏🏻

  • @sunitdeogam2100
    @sunitdeogam2100 4 года назад +6

    Helo sir, I watched all ur machine learning tutorial and can you upload videos on Time series analysis, boosting and bagging, SVM, tree model etc

  • @uditjoshi199
    @uditjoshi199 2 года назад +6

    9:46 there will be no error but I can't say what value it will print whether 0 or x but I think it should print x .
    Edit: Got it when there is no copy constructor is present in our program than complier supplies it's own copy constructor .
    12:29 : Copy constructor will be invoked because when we create object z2 then default constructor will be called because no parameters is passed to z2.
    12

  • @kushijain2393
    @kushijain2393 7 месяцев назад

    Is it necessary to always add default constructor for every constructor program we write ?
    and
    Can we use this default constructor for every type of constructor we used ?

  • @priyanshusaini7286
    @priyanshusaini7286 4 года назад +4

    Bhaiya thanks for making playlist. Hope this quarantine we learn full c++ as we have so much of time.

  • @digantachaudhuri
    @digantachaudhuri 3 года назад +13

    Best Teacher In my entire life till now love you bhaiya 🥰🥰🥰🥰

  • @itz_me_imraan02
    @itz_me_imraan02 4 года назад +22

    Need videos on competitive programming💛💚

  • @vanshmahajan9609
    @vanshmahajan9609 3 года назад +2

    Can you please explain here shallow copy and deep copy ? Thanks

  • @anshgupta738
    @anshgupta738 Год назад +1

    very good video, best explanation.

  • @altamashsabri8142
    @altamashsabri8142 4 года назад +1

    Best tutorial on C++

  • @kartikpatidar1925
    @kartikpatidar1925 4 года назад +1

    great sir you are simply great
    and happy teachers day

  • @aadityadabli
    @aadityadabli 4 года назад

    Harry bhai shandar video hai, mujhe is topic me problem aati thi ab samajh aa gya 👌

  • @sumits.parale8735
    @sumits.parale8735 2 года назад +1

    But Harry tumari video to muze bohot Anand deti hai 😁👍🙏.. thanks for awesome content

  • @ritikabali6466
    @ritikabali6466 3 года назад +2

    man, such a helpful video. thank u so much sir.

  • @samirshaikh6806
    @samirshaikh6806 3 года назад +1

    thank you harish bhai very informative tutorial

  • @BilalAhmed-7801
    @BilalAhmed-7801 Год назад

    Program same hi work kare ga copy constructor ko hide karna sa bhi

  • @sudheer4866
    @sudheer4866 3 года назад +1

    Make videos on competitive programming. Please ...

  • @sDa_E_23
    @sDa_E_23 Год назад +3

    9:45 No error
    12:29 Copy Constructor will not be invoked
    13:36 Copy Constructor will be invoked

  • @abrarahmad3897
    @abrarahmad3897 Год назад +1

    at 9:46: Since, we have assigned the default value of any object pertaining to the class Number as 0, hence, in my opinion, 0 should be returned in place of an error.

  • @te-09mrudula_chaudhari39
    @te-09mrudula_chaudhari39 4 года назад +7

    Glad to have u as a teacher sir !

  • @pratyushkurhe1577
    @pratyushkurhe1577 2 года назад

    Yes copy constructor will invoke, as just after defining the object we are equating it with another object.

  • @arnavmaheshwari6149
    @arnavmaheshwari6149 2 года назад +3

    9:38 we have a blank constructor with 0 as default value of "a" so that will be passed and there will be no error.

    • @starz144
      @starz144 Год назад

      No function is called using dot operator , only constructor is get called when object is declared. Here object of copy constructor that is x is copied to Z1 which is 0.

  • @riturajdebnath8028
    @riturajdebnath8028 2 года назад

    12:33 copy constructor not called. You are a great teacher bhaiya😃👌

  • @horainfatima2451
    @horainfatima2451 Год назад

    Great Tutorial for c++ learner

  • @PROTECHRAHUL
    @PROTECHRAHUL 3 года назад +1

    Harry bhai nested class k baare me btayiye details me please please

  • @yuktikoli9118
    @yuktikoli9118 Год назад

    thankyou so very much sir. May god bless you❤

  • @CyberrBoss
    @CyberrBoss 3 года назад +2

    What is the purpose of making a copy constructor if the compiler can create its own default constructor?
    please share some link where i can easily understand why copy constructor is needed?

  • @MotivationalGoals23
    @MotivationalGoals23 Год назад +1

    nice explanation bro

  • @nkbanerjee2549
    @nkbanerjee2549 2 года назад

    9:48--- no error as x ki value 0 hain aur hum wohi value z1 mein dal rhe hain

  • @chandrikapushpu6649
    @chandrikapushpu6649 4 года назад +18

    Please make tutorial on unity gamedevelopment

  • @AshutoshKumar-fu6qe
    @AshutoshKumar-fu6qe 3 года назад +1

    15:30 Interesting!

  • @tulas11
    @tulas11 Год назад

    You have explained it pretty well! Thank you!

  • @anandkalyanji
    @anandkalyanji Год назад +1

    By commenting out copy constructor , It will not give error beacuse default constructor is there .
    Correct me If I'm wrong .

    • @SAHIL----10
      @SAHIL----10 9 месяцев назад +1

      correct 👍👍👍

  • @vedanshpareek7605
    @vedanshpareek7605 3 года назад

    thanks harry bhaiya aapne mera bhit bada confusion solve kiya i dont have words to thank you

  • @ManishSharma-pt9fi
    @ManishSharma-pt9fi 4 года назад +2

    Can you please give a tutorial about CGI ?

  • @khizrshaikh9902
    @khizrshaikh9902 3 года назад +1

    13:23
    because we are initializing it

  • @SouvikSardar-h5r
    @SouvikSardar-h5r Год назад

    It'll work. No error will be thrown.

  • @nikunjchodvadiya2055
    @nikunjchodvadiya2055 Год назад

    timespan 12:48
    what is the output and why if we print z2 object
    z2.display();

  • @aasifsaifi5636
    @aasifsaifi5636 2 года назад

    bhai typing ke liya konsa extension liya h

  • @saradarandomworld6926
    @saradarandomworld6926 2 года назад

    bhai tum toh great ho , mein apka har video ko like karta hun , thanks bro

  • @chetansanap3398
    @chetansanap3398 4 года назад +1

    Bhai 🙏,game development using c++ ka scope , pls make video,

  • @rizwanullah3142
    @rizwanullah3142 3 года назад

    Pata nai jab youtube pe itna acha content hai tu university pe time barbad ku karie excellent
    Love from Pakistan

  • @khizrshaikh9902
    @khizrshaikh9902 3 года назад +4

    9:34
    error will occurred in my opinion
    because there are no constructor for an object

  • @kadamativenkatasai9555
    @kadamativenkatasai9555 3 года назад +1

    harry bhai if possible can you share the complete list of extensions you use in vs code
    thanks in advance

  • @laxus7764
    @laxus7764 3 года назад

    what is the need for passing the object as reference??

  • @ajaykmr8684
    @ajaykmr8684 4 года назад +14

    Please complete the playlist fast, as our internships our coming and we won't be able to get one with half skills.

  • @rizwanullah3142
    @rizwanullah3142 3 года назад

    Mughe ye play list access kiye hoi 15 din hu gayay our itna kuch seeka ke mie university mie poray aik saal mie nai seek paya

  • @Kushal145
    @Kushal145 2 года назад

    Great videos bhaiya really helpful

  • @meerapandey8792
    @meerapandey8792 4 года назад +2

    Hello Harry bhi big fan

  • @AbhishekSharma-dv2nh
    @AbhishekSharma-dv2nh 4 года назад +2

    Awesome video..☝️🔥🔥❣️

  • @Harmansingh-k1d2s
    @Harmansingh-k1d2s Год назад

    sir why we used default constructor before parametrized constructor

  • @rohantiwari5371
    @rohantiwari5371 3 месяца назад

    9:48 error aega kyunki koi aisa constructor nahi hai jo as an argument number object ko le sake.

  • @deepakgwalani406
    @deepakgwalani406 2 года назад

    time[13:34]=Yes Copy constructor will be invoked becoz z3 is made and at the same time its assign the value of z

  • @jpbprogramming2038
    @jpbprogramming2038 3 года назад +2

    Hum default constructor se factorial calculate karne ka program kyu nhi bana sakte?

  • @ThatGuy0275
    @ThatGuy0275 2 года назад

    No error will be there as it is dynamically created object 9:40 .
    13:41 yes will invoke the copy constructor.

  • @tashvikb
    @tashvikb 4 года назад +1

    Bhai c++ ke saath gaming ke upper video banaoo

  • @devdixit4111
    @devdixit4111 3 года назад

    Harry bhaiya plz makes notes of c++ with quiz with questions just like u make for c hum padh to rahe hai pr JB tak questions nhi rehege to dimag me bethege kese

  • @tusharmehra714
    @tusharmehra714 2 года назад

    bhaiya, practice questions ki bhi playlist h kya c++ ki apki banai hui, i will be awesome if u make that too just like C

  • @classmates6190
    @classmates6190 2 года назад +2

    does the copy constructor only assign value? Because at 9:30 when the default copy constructor was invoked, it automatically did the value assignment operation.

  • @pratyushkurhe1577
    @pratyushkurhe1577 2 года назад +3

    9:43 I think there should be an error, because no function has parameter as object.

  • @bytecodeskool
    @bytecodeskool 4 года назад +2

    Sir please tora jaldi Web Development wala series complete kar dijiyh

  • @royfamily9273
    @royfamily9273 2 года назад

    Thanks Harry Bhaiya

  • @minakshisharma123
    @minakshisharma123 4 года назад

    Maybe error nhi aayega bcuz reference bhi kuch kuch int ke jaisa hota h ?

  • @newsend257
    @newsend257 Год назад

    Time 12:36
    yes , invoke copy Constructors

  • @VISHAL-jw6gv
    @VISHAL-jw6gv Месяц назад

    After making the copy construction an error is occured (obj is not declared in this scope)?

  • @shyampunia6045
    @shyampunia6045 4 года назад +1

    Thank you bro!

  • @harshitjain2081
    @harshitjain2081 3 года назад +1

    Harry bhai pls make app for your website code with harry so we install the app and use in our phone

  • @abhijitmanna4524
    @abhijitmanna4524 3 года назад

    Has harry bhaiya did any question for palindrome no in c++ ?

  • @AyushiSahu-sj5zg
    @AyushiSahu-sj5zg Год назад

    Thank you

  • @XeroGamingYT
    @XeroGamingYT 3 года назад +1

    no error as we have done dynamic initialisation of the constructor.

  • @riyaraghuwanshi1038
    @riyaraghuwanshi1038 3 года назад

    Sir pehle bhi to bina default constructor bnaye program run hojata tha ab ku nhi hota ??

  • @aayushibhavsar7864
    @aayushibhavsar7864 2 года назад

    Sir can you tell me why we use reference in argument when we use object as argument of constructor please??

  • @prabhpreetsingh5897
    @prabhpreetsingh5897 3 года назад +1

    what was the significance of obj.a in the above code?

    • @sleepypanda7172
      @sleepypanda7172 3 года назад +2

      it means invoke this function:-
      Number(int num){
      a = num;
      }
      otherwise, how will the compiler deduce which constructor needs to be called?

  • @abrarahmad3897
    @abrarahmad3897 Год назад

    hey harry, here is the code:
    #include
    using namespace std;
    //complex class: handles all the functions related to complex numbers.
    class complex{
    int real,imag;
    public:
    complex(int x, int y){
    real = x;
    imag = y;
    }
    void display(){
    cout

  • @all_in_one7887
    @all_in_one7887 2 года назад

    harry bhai, ye 14:27 pe jb ek naye object to purana object creae kiyato error kiyon nhi aya? jaise jn hm kisi object ko koi value assign krte hai to we write
    Class obj= Class(a,b) .. so why you are doing Class obj2=obj not Class obj2=Class obj ??

  • @surajkumarsingh4857
    @surajkumarsingh4857 Год назад

    13:28 for Number z3 = z copy constructor will be invoked because there is no such Object with name Z3.

  • @jitendra503
    @jitendra503 4 года назад +1

    Sr plese make algorithm and data structure please

  • @ronilkansoda7140
    @ronilkansoda7140 2 года назад

    13:41 yes it will invoke ,!!!

  • @pushpakpawar7653
    @pushpakpawar7653 2 года назад

    9:41 therer will not be error but will set garbage value of z1.a

  • @simranbains6199
    @simranbains6199 2 года назад

    Thank you so much sir