Solution to Exercise on Cpp Inheritance | C++ Tutorials for Beginners #47

Поділитися
Вставка
  • Опубліковано 15 гру 2024

КОМЕНТАРІ • 180

  • @arunangshubiswas1381
    @arunangshubiswas1381 4 роки тому +136

    Could you please make a project in C++ which include many of the topics covered by you in c++ course ?

  • @manishchymanishchy902
    @manishchymanishchy902 4 роки тому +5

    You are a great teacher.I have searched many course and I haved done those. But every one's teaching method is not so learning friendly like you. That's why everyone watchs your cousrse

  • @thethinker6734
    @thethinker6734 Рік тому +1

    /*
    create 2 classes:
    1.simpleCalculator-> takes input of two numbers using utility function and perform +,-,*,/ and displays the result using another function.
    2.ScientificCalculator->takes input of two numbers using utility function and perform any four scientific operations of your choice and display the result using another function.
    Now create another Hybridcalculator and inherit the above two claases in it.
    */
    #include
    #include
    using namespace std;
    class simple_calculator{
    protected:
    float x,y;
    public:
    char opr_S;
    void set_numbers(int a,int b){
    x=a;
    y=b;
    }
    void Operands(){
    cout

    • @primeverse1745
      @primeverse1745 5 місяців тому

      Same as my code but i used if else statment switchs are better way
      Thanxs

  • @RahulYadav-jk7um
    @RahulYadav-jk7um Рік тому +5

    Challenge Accepted
    #include
    #include
    using namespace std;
    class SimpleCalculator
    {
    int a;
    int b;
    public:
    void input1(void)
    {
    cout b;
    }
    void displayresult1()
    {
    cout

  • @lovetocode9266
    @lovetocode9266 3 роки тому +6

    Thanks a lot for providing solutions ❤️❤️

  • @eeshmidha
    @eeshmidha 3 роки тому +11

    We can also make calculator using switch case (that make real one and has more sense).

    • @Elderny
      @Elderny 3 роки тому

      Indeed you can, i made one want to look?

    • @chirag4783
      @chirag4783 3 роки тому

      :)

  • @yash.05_
    @yash.05_ Рік тому +1

    I have done it correctly broo..
    I'm very happy that im going in a correct way of learning with your vedios .. thanks a lot ..

  • @altamashsabri8142
    @altamashsabri8142 4 роки тому +6

    Commenting for better reach because this guy is awesome

  • @anyda6311
    @anyda6311 5 місяців тому +1

    Harry bhaiya.. Maine bhi aap ke jaisa same banaya tha 😅thxx

  • @ayushicomputer765
    @ayushicomputer765 4 роки тому +4

    Bro I Learned HTML VERY WELL
    It's because of you

  • @bruiciedoocie3721
    @bruiciedoocie3721 2 роки тому +2

    //No special calling required. Simply create an object of HybridCalculator class and everything will happen automatically (:
    #include
    #include
    using namespace std;
    class SimpleCalculator{
    protected:
    int add(int a,int b);
    int substraction(int a,int b);
    int product(int a,int b);
    double divide(int a,int b);
    public:
    void useSimpleCalc(int num1,int num2){
    cout

    • @--kakashi
      @--kakashi Рік тому

      bro but its not memory efficient because when you inherited (HybridCalculator Class) form (SimpleCalculator Class) and (Scientific Calculator) and made an object of (HybridCalaculator Class) then all the 5 functions of (SimpleCalculator Class) and all the 5 functions of (ScientificCalculator Class) will get added in (HybridCalculator Class) then (HybridCalculato Class) have to allocate memory for all the 10 functions.
      If you just wanted to compare the user choice and run the required function then what is the point of making the class , you could have done it by just making functions.
      And also you used if() statements rather then switch() statements for just checking the user choice which made the compiler to check all the if() and else if() statements. You could have used switch() statement to just jump over the choices which make the compiler to do less work and could have made the code fast.

    • @--kakashi
      @--kakashi Рік тому

      and also another thing that why did you make even functions also if you could easily just print the result.
      wtf dude

  • @pushpender_rajput
    @pushpender_rajput 4 роки тому +1

    Love you bhai.Thanks alot You are Helping me so much.🙏🙏🙏

  • @AshutoshKumar-fu6qe
    @AshutoshKumar-fu6qe 3 роки тому +3

    a/b ko float me typecast karna chahiye th. It will not return 0 for values less than 1 and also make it precise.

  • @programmingfacts1385
    @programmingfacts1385 3 роки тому +1

    Thankyou Brother for all this videos

  • @victorb22622
    @victorb22622 7 місяців тому +1

    9:32 int की जगह float लेना था। 13:57 ambiguity दूर करने के लिए अगले वीडियो में जो लिखा था ,वो यहां दिखाया 12:30 पर ,लेकिन कुछ इस्तेमाल नहीं किया ,सिर्फ दोनो फंक्शन के मैथड के नाम rename कर दिए!

  • @ankurdahiya3611
    @ankurdahiya3611 2 роки тому +6

    Pin This Harry Bhai :
    if you verify these sin cos and tan values you'll find they are wrong but truly they aren't wrong...because sin(parameter) take values in radians not in degrees so to get correct value for degree use sin(parameter*PI/180) same for cos and tan...
    Note: here parameter is the input value in degrees
    and you need to declare PI value to 3.14159265
    Code:
    #include
    #include
    using namespace std;
    const double PI = 3.14159265;
    class SimpleCalculator{
    int a,b;
    public:
    void getdataSimp(){
    cout

  • @amangupta2130
    @amangupta2130 2 роки тому +2

    We can also use #include ?

  • @kahani_junction_s
    @kahani_junction_s 4 роки тому +2

    Great harry bhaiii thnxx

    • @usmanshahid3381
      @usmanshahid3381 3 роки тому

      Yr yeh Jo a tha wo private ni tha?? Private tu inherit hu hi ni sakta 😑

  • @priyanshkumar17
    @priyanshkumar17 Рік тому +1

    #include
    #include // OR #include
    using namespace std;
    class SimpleCalculator
    {
    protected:
    int num1, num2;
    public:
    void set_numbersSimple()
    {
    cout num1;
    cout num2;
    }
    int sum()
    {
    return num1 + num2;
    }
    int subtract()
    {
    return num1 - num2;
    }
    int difference()
    {
    return abs(num1 - num2);
    }
    int product()
    {
    return num1 * num2;
    }
    float division()
    {
    return (float)num1 / num2;
    }
    void display_01()
    {
    cout

  • @engineerbhai7642
    @engineerbhai7642 4 роки тому +1

    Thank you. You are great I. I. Tian kharagpur.

  • @wrkrebel
    @wrkrebel 2 роки тому

    awesome explanation

  • @abhirashmikumari8097
    @abhirashmikumari8097 4 роки тому +3

    thank you harry :)

  • @karandeepkhosa7580
    @karandeepkhosa7580 10 місяців тому

    /*
    1. I am using multi-level inheritance
    2. public mode
    3. code reusability is implemented in this programm by using multi-level inheritance
    */
    #include
    using namespace std;
    class simpcal
    {
    protected:
    int a,b;
    public:
    int x,y;
    void setvalues()
    {
    a=x;
    b=y;
    }
    void displaysimp()
    {
    cout

  • @gujjubhai6149
    @gujjubhai6149 4 роки тому +5

    U r legend 💪..

  • @Noob-be3dg
    @Noob-be3dg Рік тому

    Love you Harry bhai dil se ❤

  • @ashpreetsinghanand7260
    @ashpreetsinghanand7260 4 роки тому +4

    Ab bhaiya ek project banao class ki help se taki aur mazza aye😁

  • @Abc-rz4ps
    @Abc-rz4ps 11 місяців тому

    /*
    Create 2 classes:
    1. SimpleCalculator - Takes input of 2 numbers using a utility function and performs +, -, *, / and displays the results using another function.
    2. ScientificCalculator - Takes input of 2 numbers using a utility function and performs any four scientific operations of your choice and displays the results using another function.
    Create another class HybridCalculator and inherit it using these 2 classes:
    Q1. What type of Inheritance are you using? //multiple inheritance
    Q2. Which mode of Inheritance are you using? //Public inheritance
    Q3. Create an object of HybridCalculator and display results of the simple and scientific calculator.
    Q4. How is code reusability implemented?
    */
    #include
    #include
    using namespace std;
    class SimpleCalculator{
    protected:
    int n1,n2;
    public:
    void takeval(){
    cout

  • @Riyaz48
    @Riyaz48 4 роки тому +1

    Very Big fan Harry bhai

  • @krishnamahto356
    @krishnamahto356 4 роки тому +1

    bro u are great

  • @RahulSingh-tt3fk
    @RahulSingh-tt3fk 9 місяців тому +1

    include
    #include
    using namespace std ;
    class simplecalculator{
    protected:
    float a,b;
    public:
    void set_numbers(float l,float k){
    a=l;
    b=k;
    }
    void calculation1(){
    cout

  • @tusharverma2249
    @tusharverma2249 3 роки тому +6

    5:52
    Are harry bhai kya baar baar save karo, uper file me jaake auto save on kardo na.

  • @laveetkumar717
    @laveetkumar717 4 роки тому +3

    sir plz make some projects jese apne pythone ke course me game banayi hai as a project so plz make projects by c++

  • @giyu9088
    @giyu9088 4 роки тому +7

    Please make a tutorial on Deep learning with tensorflow ♥️

  • @royfamily9273
    @royfamily9273 2 роки тому

    Thanks Harry Bhaiya

  • @Juo90
    @Juo90 2 місяці тому

    i used get data as 1st class operation in derived class and solution as multiple derivation of both data initializer and operation to show result the aim was to try as many oops concept in it

  • @praveenkumar-hk7vp
    @praveenkumar-hk7vp 4 роки тому +1

    Nice video 👌

  • @maheshmistry3685
    @maheshmistry3685 4 роки тому +2

    Please make a tutorial for computer architecture and organisations

  • @mdmatiurrahman7373
    @mdmatiurrahman7373 4 роки тому +1

    Sir. Love from Bangladesh. ...
    I have a request for you... plzzzzzz make videos on WordPress. ........plzzzzzz
    Thank you for everything. .....
    And respect for you
    ....
    Tnx..
    #wordpress
    #tnx
    Bye. .....
    And plz reply to this comment. ......

  • @muhammadadeel3989
    @muhammadadeel3989 2 роки тому

    cout

  • @divysrivastava3696
    @divysrivastava3696 4 роки тому +1

    Bhaiya please Oops in Python par video bna dijiye 🙏🙏🙏🙏

  • @pratyayansarkar4124
    @pratyayansarkar4124 4 роки тому +1

    Not great but greatest and the best... Love u bro ..

  • @chandankeshari6600
    @chandankeshari6600 3 роки тому +1

    i think i made more advanced and friendly calculator
    here i do not meant that haary sir you make very simple program
    but i want to show you and wants your sugguestion on it

  • @kumkumbhagya51
    @kumkumbhagya51 Рік тому

    4:27 kiya tha maine solve par jab aap solve kr rhe ho to aur bhi ache se samajh aa rha hai like suddenly solution ko dekhne ka nazariya badal gya jaise hi aapne solve krna shuru kiya

  • @satyamrajsat5366
    @satyamrajsat5366 3 роки тому +1

    Respected harry sir kya scientific calculator me +,_,*,/ nahi hota hai.
    if I use these oparations in scientific calculator then we have to use virtual in simple calculator.right sir??

  • @aanshmattoo9306
    @aanshmattoo9306 2 роки тому +1

    By any way can we use both simple and scientific calculator in hybrid by accepting the value of a & b only once.

    • @anonymous_ghost_123
      @anonymous_ghost_123 2 роки тому +2

      yes we can do that by using single inheritance on classes simple and scientific...
      after that we can use the variables a and b in both of the classes...

  • @csea_37_shayoribhowmick53
    @csea_37_shayoribhowmick53 2 роки тому

    Thank you so much Harryyyyyyy

  • @anotech4411
    @anotech4411 2 роки тому

    #include
    #include
    using namespace std;
    class Simplecalculator{
    private:
    int x,y;
    public:
    void setdata(){
    couty;
    }
    void simple(){
    cout

  • @manojbhakta4942
    @manojbhakta4942 Рік тому

    class HybrideCalculator : public SimpleCalculator,public ScientificCalculator{
    };
    Simple calculator and then Scientific calculator can be done whithout writing it 🙃✌

  • @bhawanagupta7323
    @bhawanagupta7323 4 роки тому

    Love u bro.🖤🖤. plzz make a PDF of website questions...🙏🙏

  • @deepakgwalani406
    @deepakgwalani406 Місяць тому

    Sir can we do it with multilevel inheritance by this way we will not get ambiguity at time of setting the variables . But in this we have to do variable public.

  • @apurvasonawane5049
    @apurvasonawane5049 3 роки тому

    Thank you

  • @kunalshahare9041
    @kunalshahare9041 3 роки тому

    thank you bhai

  • @kumarharsh90
    @kumarharsh90 4 роки тому

    Improving reach

  • @thesoloentrepreneur07
    @thesoloentrepreneur07 3 роки тому

    ambiguity resolution use nhi kia?

  • @vaibhavgupta4413
    @vaibhavgupta4413 4 роки тому

    Great video

  • @prachi55356
    @prachi55356 2 роки тому

    Harry bhai
    Aisa kar sakte hai kya ki
    Input sirf one time lena pade user se and all the operations are performed once ?
    If yes how?

  • @_Dipanshukhetawat
    @_Dipanshukhetawat 4 роки тому +1

    Please make video on app development for project

  • @me30prashantbabu88
    @me30prashantbabu88 3 роки тому +1

    harry bhaii ,
    a , b to private members the base classes me
    frr vo hybridcalculator vaali class me inherit kese ho gye aapke solution me

    • @beeta140yashghugare2
      @beeta140yashghugare2 3 роки тому +1

      bhai usne a,b ko direct access nhi kiya ,balki by using mehod kiya isliya error nhi aaya

    • @only_for_fun1234r
      @only_for_fun1234r 3 роки тому +1

      Using function we can access

  • @hajimeippo804
    @hajimeippo804 3 роки тому

    Please give us task in every video like this

  • @deepakdeodattmishra7981
    @deepakdeodattmishra7981 4 роки тому +1

    Big fan first❤️

  • @abdullahsajjad3516
    @abdullahsajjad3516 4 роки тому

    Harry bhai please make tutorials on React Native JavaScript Android App Development

  • @kashyapsantoki4889
    @kashyapsantoki4889 4 роки тому

    Biggest fan ever

  • @riyaaa2811
    @riyaaa2811 3 роки тому

    You are amazing...

    • @usmanshahid3381
      @usmanshahid3381 3 роки тому

      Yr yeh Jo a tha wo private ni tha?? Private tu inherit hu hi ni sakta 😑

    • @riyaaa2811
      @riyaaa2811 3 роки тому

      @@usmanshahid3381 a and b dono private hai..agar aap usko define nahi karte ho toh vo private function he hote hai.

  • @funtoptutorial7146
    @funtoptutorial7146 4 роки тому

    Harry bhia plzz aak python se extension banan sikho...
    Jise koi bhi flash sale phone ko buy krne me help kre.....
    Amazon ya flipkart se

  • @tarunaggarwal1063
    @tarunaggarwal1063 4 роки тому

    Thnc bro it is useful

  • @S_seriess566
    @S_seriess566 2 роки тому

    either sir we can use switch function for it... for simple calculator isnt it
    sir??

  • @sujayshekhar5916
    @sujayshekhar5916 4 роки тому

    Sir please ek video banao jisme django models ke har field ke bare me batao jaise manytomany foreign key waigrh saaree ache se explain krdo sir plsss 🙏🙏🙏🙏🙏

  • @avirupmazumder4840
    @avirupmazumder4840 3 роки тому +1

    Sin() and cos() ka value sehi nahi ho rah hain ?

    • @chirag4783
      @chirag4783 3 роки тому

      mtlb?

    • @niteshbovi769
      @niteshbovi769 3 роки тому

      Enter the value in radian mode or convert the degree value into radian and pass the value to fnction

  • @RohanDasRD
    @RohanDasRD 4 роки тому

    Good video bro

  • @last_countr_
    @last_countr_ 4 роки тому +1

    Bhai Kabhi live bhi aao
    Qna krna please

  • @pratapjoshi6954
    @pratapjoshi6954 3 роки тому

    I use switch case so we can perform specific Operation

  • @maazajaz1944
    @maazajaz1944 2 роки тому +2

    //my code
    #include
    #include
    using namespace std;
    /*
    Create 2 classes:
    1. SimpleCalculator - Takes input of 2 numbers using a utility function and performs +, -, *, / and displays the results using another function.
    2. ScientificCalculator - Takes input of 2 numbers using a utility function and performs any four scientific operations of your choice and displays the results using another function.
    Create another class HybridCalculator and inherit it using these 2 classes:
    Q1. What type of Inheritance are you using?
    Q2. Which mode of Inheritance are you using?
    Q3. Create an object of HybridCalculator and display results of the simple and scientific calculator.
    Q4. How is code reusability implemented?
    */
    class simpleCalculator
    {
    float a,b;
    public:
    void getDataSimple()
    {
    cout

    • @AdarshKumar-bp6bc
      @AdarshKumar-bp6bc 2 роки тому

      I also made same.. it looks more accurate as a calculator

    • @maazajaz1944
      @maazajaz1944 2 роки тому

      @@AdarshKumar-bp6bc hmm thanks 😅

  • @paritoshkabra712
    @paritoshkabra712 4 роки тому +2

    How the private variables of base classes in the program were excessed by the inherited class when the get_data function was called?....anyone?

    • @nishankkankas7195
      @nishankkankas7195 3 роки тому

      same ques

    • @shubhamghildiyal8173
      @shubhamghildiyal8173 3 роки тому +3

      The private functions cannot be called directly by the inherited class..the inherited class has to use an inherited function(getdata) to call the private variables..

    • @Yash-wf5lg
      @Yash-wf5lg 3 роки тому

      its because it is using the base function so if we create a function in derieved class and try to use a,b it will give an error.
      so the thing is that i created a function print(){ cout

    • @ankurdahiya3611
      @ankurdahiya3611 2 роки тому

      @paritosh Kabra its because the program we called in derived class is public you can access public function anywhere in code but you can't access private datamembers of its class so if you will try to access a and b directly in derived function you cant do that. Hope this helped

  • @titasmajumder3983
    @titasmajumder3983 2 роки тому

    Harry bhaiyaa what is the difference between cmath and math.h?

  • @mohammadusman5345
    @mohammadusman5345 4 місяці тому

    i rly overthought this exercise man
    #include
    #include
    using namespace std;
    class SimpleCalculator
    {
    public:
    char choice;
    int a, b;
    void setnum(int x, int y)
    {
    a = x;
    b = y;
    }
    int mul()
    {
    return a * b;
    }
    int add()
    {
    return a + b;
    }
    int sub()
    {
    return a - b;
    }
    int div()
    {
    if (b != 0)
    {
    return a / b;
    }
    else
    {
    cout

  • @tahorearshad8417
    @tahorearshad8417 4 роки тому

    Harry bhai software development ka full course kahan mile ga

  • @DharmendraSingh-ge9ej
    @DharmendraSingh-ge9ej 4 роки тому

    Bhai please make complete " Java" series please bhai 🙏🙏🙏🙏🙏

  • @Yash-wf5lg
    @Yash-wf5lg 3 роки тому

    so the thing is that i created a function print(){ cout

  • @shashijaiswal688
    @shashijaiswal688 3 роки тому +1

    i have used 2.7182 instead of exp.

  • @ashokebasak8900
    @ashokebasak8900 4 роки тому

    Sir how to code ai in pydroid or qpython ?????

  • @uttamkarmakarece3534
    @uttamkarmakarece3534 3 роки тому

    Bhaiya please video dalo na ish playlist me...kabse video nhi a raha

  • @DharmendraSingh-ge9ej
    @DharmendraSingh-ge9ej 4 роки тому

    Bhai please make complete course on Java please bhai 🙏🙏🙏🙏🙏

  • @manoor0858
    @manoor0858 4 місяці тому

    #include
    using namespace std;
    class SimpleCalculator
    {
    int a;
    int b;
    public:
    void set1(int x, int y)
    {
    a = x;
    b = y;
    }
    protected:
    void print1()
    {
    printf("Sum is %d
    Difference is %d
    Muliplication is %d
    Division is %f
    ", a + b, a - b, a * b, a * 1.0f / b);
    }
    };
    class ScientificCalculator
    {
    int c;
    int d;
    public:
    void set2(int x, int y)
    {
    c = x;
    d = y;
    }
    protected:
    void print2()
    {
    cout

  • @ashokkapse6815
    @ashokkapse6815 Рік тому

    I have done it but used switch case so i have control on what operation program is doing

  • @Rajakumar-ls1rx
    @Rajakumar-ls1rx 4 роки тому

    hello sir maina apki sari videos dakhi ha apka samjhana ka tarika bohat acha laga mujha sir ek app ko confg kar rha hu android studio mai but kuch error a rha ha to please aap help kijiya please sir

  • @chinmaylute1571
    @chinmaylute1571 3 роки тому

    Harry bhai division me decimal number nahi arhe hai..

  • @trending_shorts9999
    @trending_shorts9999 Рік тому +1

    hey guys here is the solution :
    .
    .
    .
    v
    #include
    #include
    using namespace std;
    class simple_calculator{
    protected:
    int a,b;
    public:
    void set_numbers( int num1 , int num2){
    a=num1;
    b=num2;
    }
    void print_numbers(void){
    cout

  • @maabaglamukhistudycircle999

    Hye sir data Science c++ ke video bnao

  • @taruny6051
    @taruny6051 4 роки тому

    Please make tutorials on unity coding.plzz

  • @AshokKumar-vg7tg
    @AshokKumar-vg7tg 4 роки тому

    Harry bhai you have not check my program ,that I commented in video no. 42 please check it once and correct my mistakes..

  • @Developer_Rohit_Choudhary
    @Developer_Rohit_Choudhary 8 місяців тому

    mene to conditions aur constructors laga ke kiya tha

  • @alianoor7249
    @alianoor7249 3 роки тому

    Sir ek topic pr 5 qstions at least mil jata
    . practice krne ko toh sahi hota h..plzz sir..plzz

  • @amartyasen4871
    @amartyasen4871 3 роки тому

    operator overloading padha do bhaiya

  • @nomantufail1669
    @nomantufail1669 2 роки тому

    can anyone tell me when the data members from both the classes i.e., a simple calculator and scientific calculator are inherited by the hybrid calculator, why we did not create virtual base classes? as the hybrid class will have ambiguity about the data members?

    • @sohelunknown5499
      @sohelunknown5499 2 роки тому

      No hybrid class will not get ambiguity.... Because the data members in simple calculator and scientific are different... We get ambiguity only when data members gets repeted... If simple calculator and scientific calculator are inherited from any other class then we would get ambiguity

  • @ayushsatecsh9930
    @ayushsatecsh9930 4 роки тому +1

    Bhai mein aapse pichle 3 videos se puch raha hu programming setup ke upar ek video banane keliye aap tho reply bhi nhi kar rahe ho bhai please is matter ko dekho....

  • @bhaktiswain5746
    @bhaktiswain5746 4 роки тому

    Plese sir make a video of c++game
    And what we can do with c++

  • @samirshaikh6806
    @samirshaikh6806 4 роки тому

    Constructors in Derived Class in C++

  • @riteshsah4904
    @riteshsah4904 3 роки тому

    operator overloading kaa topic baaki hai c++ may

  • @harshsinghania3
    @harshsinghania3 4 роки тому

    Bhai web development plz with java css and html

  • @princesukhala7106
    @princesukhala7106 2 роки тому

    Done