Lecture 26 Type Conversion one class type to another class type in C++ Hindi

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

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

  • @pragyasengar8573
    @pragyasengar8573 3 года назад +6

    its so fun to study from Saurabh Sir, Sir you're doing great ! coding seems like exploring !

  • @madhusudanpatil3509
    @madhusudanpatil3509 4 года назад +30

    Sir, this is what I have coded for class to class type conversion using casting operator.. please, check it once... however output is correct I have done using code blocks
    # include
    using namespace std;
    class item
    {
    private :
    int m,n;
    public:
    void setm(int x)
    {m=x;}
    void setn(int y)
    {n=y;}
    void showdata()
    {cout

    • @ManjeetKumar-eq1lc
      @ManjeetKumar-eq1lc 3 года назад +1

      Thank u bhai

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

      operator item()
      {
      item i1;
      i1.setData(a,b);
      return i1;
      }

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

      Thanks a lot Man !!!
      You should edit this command and add space between some lines for better understanding

  • @remindit2504
    @remindit2504 Год назад +5

    Sir aap bahut galat kaam kar rahe hai. Itna achha mat padhaiye. Hame sirf aapke video hi samajh aate hai. agar kisi topic par aapka video nahi bana hai to samajhane me bahut takleef hoti hai. Seriously BEST COACH I ever seen in my life. Keep it up.

  • @akmfaisal6463
    @akmfaisal6463 9 лет назад +3

    I'm very thankful to you, I learned a lot from your videos. Can you please make 1 video for Dynamic casting..

  • @PAWANKUMAR-el2zk
    @PAWANKUMAR-el2zk 4 года назад +1

    Thankyou sir your explanation is unique and awesome !! I think U are the one of the most good explainer sir really !! 👍

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

    Thank you very much. You are a genius.

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

    Use of Casting Operator.
    #include
    #include
    #include
    using namespace std;
    class item
    {
    private:
    int a,b;
    public:
    void setData(int x,int y){
    a=x; b=y;
    }
    void showData(){
    cout

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

      How can you call set(m) by items object

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

      @@easylife2482 In this code are not able to only set(m) but you can do make some changes in gater and seter.

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

      Suryapratap singh you have infinite knowledge. You are brilliant genius God father of Albert einstein

  • @SaurabhKumar-uw2tc
    @SaurabhKumar-uw2tc 2 года назад

    Very nice lecture line by line ploblem solve coding through thanku sir g

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

    great video !

  • @krishnakrmahto97
    @krishnakrmahto97 6 лет назад

    Sir, product data members can be accessed within a function (and also a constructor) if an object of that class is passed as an argument to that function..so, here it would have worked without getM() function.

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

    graet explation sir_____thank you

  • @abhishekkumarsingh766
    @abhishekkumarsingh766 6 лет назад

    i am very thankuful to u sir,ur teaching style is too good

  • @sagarojha3491
    @sagarojha3491 6 лет назад +2

    sir please make a video on static and dynamic casting, I am confused in early binding problem because of these topics.

  • @alokranjansrivastava623
    @alokranjansrivastava623 4 года назад +5

    We can use parameterized constructor of item class to perform operator casting.
    i1 = p1; // p1.operator Item();
    In Product class
    operator Item()
    {
    Item temp(m,n);
    return(temp);
    }

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

      Thankyou so much sir.
      I was thinking about how we can do it by making the whole class as Friend Function and then accessing member variables through dot format, but in this case we need to have Arguments of that class which is not possible in Casting Operator.

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

    Thank you sir for such a wonderful lecture.... 😊😊😊

  • @rajamehran5387
    @rajamehran5387 7 лет назад

    thank you very much...all of your helped a lot sir...thanks
    i hope more videos about the programming language will be added in the future

  • @purnaamdoli3722
    @purnaamdoli3722 7 лет назад +9

    sir make a video on casting operator also

  • @goutamnagpal3912
    @goutamnagpal3912 5 лет назад +3

    By Casting operator for reference .
    #include
    using namespace std;
    class product;
    class Item
    {
    int a,b;
    public:
    Item()
    {}
    void PutA(int a)
    {
    this->a = a;
    }
    void PutB(int b)
    {
    this->b = b;
    }
    friend void show(Item ,product );
    };
    class product
    {
    int a,b;
    public :
    product()
    {
    cin>>a;
    cin>>b;
    }
    operator Item()
    {
    Item I;
    I.PutA(a) ;
    I.PutB(b);
    return I;
    }
    friend void show(Item ,product );
    };
    void show(Item I,product P)
    {
    cout

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

      thanks bro your code is useful for me.....

  • @rishabhtripathi5530
    @rishabhtripathi5530 7 лет назад +7

    please upload the video of clas to class conversion using casting operator

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

      #include
      using namespace std;
      class item
      {
      int m,n;
      public:
      item(){
      }
      item( int a,int b)
      {
      m=a;
      n=b;
      }
      void show()
      {
      cout

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

      @@pratikpandey3651 Brother Can you explain your code? It's urgent

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

    We can use friend function to get values of m and n

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

    We can also inherit the product class in the item class

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

    Awesome Lecture 👍
    Thank you sir 🙏

  • @shrishchamoli
    @shrishchamoli 9 лет назад +4

    thanks sir for the amazing explanation

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

    please make video on class to class conversion using casting operator

  • @ajr1791ze
    @ajr1791ze 5 лет назад

    we can eliminate default const. error using item i1 = p1 in the fiirst line itself rather than assigning it explicitly.

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

    what a pleasure to learn from you!!!!!

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

    Perfection

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

    humne constructor main Product ka hi object bna diya h sir isme hmen Product ka refernce varible nai bnaaa skte the kya aesa krne pr ek constructor or bn jayega

  • @GAUTAMKUMAR-or7rh
    @GAUTAMKUMAR-or7rh 4 года назад +6

    Sir, product class ke members ko access karne ke liye item class me friend function bana sakte hai kya.....?
    Humlog constructor ko hi friend function bana sakte hai product class ke liye.
    Ref. Lecture 12 part 6

  • @suryabhusal1527
    @suryabhusal1527 7 лет назад

    Your Explanations are great sir.

  • @sakshiagarwal3666
    @sakshiagarwal3666 9 лет назад +3

    best explanation thank u sir

  • @darshantechful
    @darshantechful 7 лет назад +2

    Plz sir i requeste you send me CLASS TO BASIC and BASIC TO CLASS TYPE CONVERSION program with exaplanation....
    thank you sir

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

    We could declare item class a friend of product class so that we can access the private member of product class in item class...

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

      Another approach could be we can make item constructor a friend of product class.

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

    Thanks sir i easily understand

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

    Thank you sir,good explanation 😊

  • @meghachowdhury2088
    @meghachowdhury2088 6 лет назад

    Please make a video on casting operator also

  • @vineet9singh
    @vineet9singh 9 лет назад +2

    Sir jo product main 'p' likha h wo khi declare to kya nhi or main m p1 declare h instead of p.

    • @cbysaurabhshuklasir32
      @cbysaurabhshuklasir32  9 лет назад

      +Vineet Singh Product p1; It means p1 is an object of class Product. yeh main mein declare kiya hai. p kahin bhi nahi likha hai, sabhi jagah p1 hai. Fir bhi agar kahin meine dekh nahi pa raha hun to please batayein. Thanks for watching

    • @vineet9singh
      @vineet9singh 9 лет назад

      void showData()
      { cout

    • @DeepakKumar-tr5fn
      @DeepakKumar-tr5fn 7 лет назад +1

      Vineet Singh p is argument of constructor product, it is not p1 object. so you should not confuse about this.

  • @anujbirani3771
    @anujbirani3771 7 лет назад

    Sir casting operators kya hote h and how they are different from type conversion please explain through videos .
    Thank you;

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

    Thank you sir. you are just great.

  • @hello_shum
    @hello_shum 6 лет назад +1

    operator item ( )
    {
    item temp;
    temp.a=i2.m;// i think i am doing sth wrong here ?
    temp.b=i2.n;
    return(temp);
    }
    now in main()
    {
    item i1;
    product i2;
    i2.setData(3,4);
    i1=i2;// i1=i2.operator int(); just to revise
    i1.showData();
    }
    Is it correct sir, for casting operator.
    or should i have to use member function to get the value of a and b in line no:4 and 5. Please help. Nahi to neend nahi ayegi sir. :)
    Regards.

    • @alroygama6166
      @alroygama6166 5 лет назад

      You didn't sleep for a year?🧐

    • @PramodYadav-il2gk
      @PramodYadav-il2gk 5 лет назад

      #include
      #include
      using namespace std;
      class item
      {
      int a,b;
      public:
      void showdata()
      {
      cout

  • @vaibhavbhansari4830
    @vaibhavbhansari4830 7 лет назад

    plz also upload video using casting method

  • @anirajsoni300
    @anirajsoni300 5 лет назад

    sir, the line " i1=p1;" should call the implicit copy assignment operator created by compiler ,not the copy constructor but why it is calling copy constructor ?
    i have checked for same class object , it calls the assignment operator not copy constructor

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

    World class explanation

  • @PAWANKUMAR-el2zk
    @PAWANKUMAR-el2zk 4 года назад

    And how can u do this, really wonderful

  • @anantmishra4893
    @anantmishra4893 5 лет назад +1

    Sir please make a video on casting operator also, its a humble request sir

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

      #include
      using namespace std;
      class jaa;
      class mayu
      {
      int a,b;
      public:
      mayu(){}

      void setdata(int a,int b)
      {
      this->a=a;
      this->b=b;
      }
      void showdata(void)
      {
      cout

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

      #include
      using namespace std;
      class item
      {
      int a,b;
      public:
      // item(){}
      // item(product &ob){a=ob.getm();b=ob.getn(); }
      void set(int x,int y)
      {
      a=x;b=y;
      }
      void show()
      {
      cout

  • @vinayakgupta8286
    @vinayakgupta8286 8 лет назад

    Hello Sir! Sir in main function you've created object of Item type therefore making default constructor u made later to get executed but Sir then how is constructor Item(Product p) gets executed even though we haven't even pass any parameter of product type in its paranthesis or created any object like Item i2(Product p1) and in that case will writting this will be correct or not Product p1; Item(p1); ?
    Regards.

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

    Why we are not passing the reference of Product object ? It should ideally get into trap of creating object of Product class each time ?

  • @anilsharma-cd2hq
    @anilsharma-cd2hq 6 лет назад +6

    sir please, casting operator wali video or upload kar do

    • @ayeshasiddiqua1037
      @ayeshasiddiqua1037 5 лет назад +6

      Here is an example which shows the type conversion from primitive to class, class to primitive and the two cases of class to class conversion.
      During class to class conversion using constructor the class whose object value is being copied should be placed above (unit class in the below example) and during the operator casting the class in whose object we want to copy data should be placed above (general class in the below example). Hope it helps.
      #include
      #include
      using namespace std;
      class unit{
      int k;
      public:
      unit () { }
      // unit (general g) // using constructor class to class conversion
      // { k = g.geta(); }
      void setdata(int a)
      { k=a; }
      void showdata()
      { cout

    • @PramodYadav-il2gk
      @PramodYadav-il2gk 5 лет назад +6

      #include
      #include
      using namespace std;
      class item
      {
      int a,b;
      public:
      void showdata()
      {
      cout

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

      @@ayeshasiddiqua1037 Amaze......

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

      @@PramodYadav-il2gk u r insane Super

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

      @@PramodYadav-il2gk bro ye program mene compile karke dekha run nahi ho raha .... proper solution aap muje bata sakte haii?????plzz

  • @prayagparikh8020
    @prayagparikh8020 6 лет назад

    You are excellent sir
    But what about casting operator

  • @mohammedsuhailbasha4860
    @mohammedsuhailbasha4860 5 лет назад

    Sir here we passing object as argument to constructor sir, than why you do not make copy constructor sir.pls explain sir

  • @axc4280
    @axc4280 5 лет назад +3

    Sir.. Casting Operation me ..Private member ko value dene k liye access kaise kare??

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

    Nice explanation

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

    Awesome

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

    Well explained!😃✌🏻

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

    this task can also be done using friend function

  • @radhatiwari2748
    @radhatiwari2748 7 лет назад

    Sir please show a vedio of casting operator of example shown in the same vedio

  • @memesexpert9868
    @memesexpert9868 6 лет назад

    Jb I1=P1 krenge तो dono check hoga kya sir.... ki conversion constructor ke through krna h ya casting operator ke.... kaunsa pahle check hoga

  • @raghavdhawanartist2508
    @raghavdhawanartist2508 6 лет назад

    Sir u didn't posted a video on th class to class type by casting operator or type conversion operator.. plz put a video on this..req

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

    Sir what i have to do in which task of
    Typeconversion of 2 classes are asked simultaneously?

  • @pkasturi4750
    @pkasturi4750 6 лет назад

    sir,please upload RTTI videos and dynamic casting videos sir,please....

  • @YDbabakebolYashodipShete
    @YDbabakebolYashodipShete 8 лет назад

    I need ur book or DVD😊 because in my rural area there is problem in internet source😢 so plz help me😮

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

    Sir please add video of conversion using casting operator...

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

      Here it is:
      #include
      using namespace std;
      class Product
      {
      private:
      int pnum1;
      int pnum2;
      public:
      void setnumber(int px, int py)
      { pnum1= px; pnum2 = py; }
      void display()
      { cout

  • @aniketk11
    @aniketk11 6 лет назад

    Sir please make video for casting operator

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

    Sir agar ham isme ek aur object bnae jo ek int argument le rha h aur uske liye constructor bnae to vo error de rha h sayad x=c1 us constructor ko bhi call kar rha h usi time jis time vo oprator ko call kar rha h

  • @NishantSharma-sd6yv
    @NishantSharma-sd6yv 2 года назад +1

    Using casting operator
    operator Item() {
    Item i(m,n);
    return i;
    }

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

    Sir, please make this video with Casting operator, plsssssss sir

  • @amriteshsingh9193
    @amriteshsingh9193 7 лет назад +1

    please upload class to class conversion using casting operator

  • @muskanmehar8043
    @muskanmehar8043 5 лет назад

    Sir m or n varible or product class m public mh kr skte lya to getm or getn function bnane k bjh

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

      phir koi bhi akpe data ko change ker sakta hai isliye private rakhate hai

  • @aman_
    @aman_ 6 лет назад

    Sir you are great.

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

    Sir explicit constructor kya hota hai?

  • @shrikantnavghare659
    @shrikantnavghare659 6 лет назад

    Sir please upload an video on operator casting please!!!

  • @ehtixhamamjad
    @ehtixhamamjad 5 лет назад

    thanks for help MysirG

  • @snehajitchandra2976
    @snehajitchandra2976 6 лет назад

    Fantastic video Sir

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

    U r great

  • @mehulprajapati5326
    @mehulprajapati5326 6 лет назад

    Nice.. Sir...
    Pls upload class to class type conversation using casting operator... We r getting error as private variable unable to access also upload vedeo for access private variable using friends... If possible

    • @prasangsinghal262
      @prasangsinghal262 6 лет назад

      mehul prajapati make it public...we don't have any other option...

    • @mehulprajapati5326
      @mehulprajapati5326 6 лет назад

      Prasang S... If use public then no need of privet... May b possible other way to describe using casting operator type... Sirji upload this video and show new path to us....

    • @prasangsinghal262
      @prasangsinghal262 6 лет назад

      My teacher shared a program with me.... in that it was public....so I thought it's necessary to use public instead of private...

    • @debashishdas2514
      @debashishdas2514 6 лет назад +1

      dnt make the variables public... instead jst use functions to Set values to member variables.... U can call those functions from Casting fun. and pass the values

    • @abhaysharma2682
      @abhaysharma2682 5 лет назад

      @@debashishdas2514 Thanks, brother!

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

    Nice

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

    god level sir

  • @munish.semwal
    @munish.semwal 6 лет назад

    so it means ke ek object ke sath dono constructor call ho rahe hai?

  • @tlpunisher42
    @tlpunisher42 5 лет назад

    Here why reference of p is not used in the constructor?????

  • @hiteshkushwaha7585
    @hiteshkushwaha7585 7 лет назад +7

    sir can we declare constructor of 1 class as friend function to another class.

  • @pinkeshpatel619
    @pinkeshpatel619 5 лет назад

    Superb

  • @AdityaKumar-ws5pv
    @AdityaKumar-ws5pv 7 лет назад

    sir casting operator wala method mai kya likha jaega bata dijiye error aa raha hai.Thank you sir you r doing a gr8 job.

  • @pogoclub8495
    @pogoclub8495 7 лет назад +1

    conversion from one class type to another by casting function

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

    Thank you sir

  • @suryateja4776
    @suryateja4776 7 лет назад

    sir how to compare two strings of the same class usin '=='operator overloading
    sir please give me reply as early as possible

  • @akashdohare8694
    @akashdohare8694 5 лет назад +1

    instead of using getM() and getN() we can me class item friend class of class product

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

    Thanks

  • @devanshisoni3532
    @devanshisoni3532 6 лет назад

    Sir,if I declare two constructors in item class so I declare default constructor or not??

    • @anujgupta3397
      @anujgupta3397 6 лет назад

      yes,u hv to declare default constructor whenever you declare custom constructor

  • @goodforyou7689
    @goodforyou7689 5 лет назад

    Thanks a lot

  • @Roy-fr6yr
    @Roy-fr6yr 5 лет назад

    sir wo m n ko private ki jagah protected bhi toh ker skte hai na?

  • @nargeesansari6337
    @nargeesansari6337 5 лет назад

    thank u soo much sir

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

    operator item()
    {
    item i1;
    i1.setData(a,b);
    return i1;
    }

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

    Solution using casting operator :
    #include
    using namespace std;
    class Item{
    private:
    int a,b;
    public:
    void showData(){
    cout

  • @syednoorullahshah9194
    @syednoorullahshah9194 6 лет назад

    can we use friend class concept ???

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

    can we use template to convert any type.

  • @shivamsoni1528
    @shivamsoni1528 7 лет назад

    how to solve problem if variables is not in both class ??

  • @universeboss1
    @universeboss1 6 лет назад

    scroll slowly kijiye taki coding notedown kar sake

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

    Ab to chhap gya hai deemag me
    Jab bhi hum Koi constructor bna dete hai class me to compiler default constructor nhi banata

  • @forbiddenumbrella
    @forbiddenumbrella 6 лет назад

    sir wo parenthesis wala error code blocks me bhi aata hai.. uska reason batao sir

  • @genius_7419
    @genius_7419 5 лет назад

    Can we use friend function here