Parameterized and Default Constructors In C++ | C++ Tutorials for Beginners #30

Поделиться
HTML-код
  • Опубликовано: 7 сен 2024
  • Download the best IDE for C, C# and C++: bit.ly/WholeTo...
    ►Source Code & Resources: codewithharry....
    ►This video is a part of my C++ playlist: • C++ Tutorials In Hindi
    ►For Doubt Solving, Brain Storming Sessions & guaranteed replies, join the channel membership here: / @codewithharry
    ►Click here to subscribe - / @codewithharry
    ►Checkout my English channel here: / programmingwithharry
    Best Hindi Videos For Learning Programming:
    ►Learn Python In One Video - • Python Tutorial In Hin...
    ►Python Complete Course In Hindi - • Python Tutorials For A...
    ►C Language Complete Course In Hindi -
    • C Language Tutorials I...
    ►JavaScript Complete Course In Hindi -
    • JavaScript Tutorials I...
    ►Learn JavaScript in One Video - • JavaScript Tutorial
    ►Learn PHP In One Video - • Learn Php In One Video...
    ►Django Complete Course In Hindi -
    • Python Django Tutorial...
    ►Machine Learning Using Python - • Machine Learning Tutor...
    ►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
    ►Advanced Python Tutorials - • Intermediate/Advanced ...
    ►Object Oriented Programming In Python - • Object Oriented Progra...
    ►Python Data Science and Big Data Tutorials - • Python Data Science an...
    Follow Me On Social Media
    ►Website (created using Flask) - www.codewithhar...
    ►Facebook - / codewithharry
    ►Instagram - / codewithharry
    ►Personal Facebook A/c - / geekyharis
    Twitter - / haris_is_here

Комментарии • 1,1 тыс.

  • @vaishnavihud1666
    @vaishnavihud1666 Год назад +122

    //create a function which takes two point objects and computes the distance between those two points
    //Hint :make it a friend function
    #include
    #include
    using namespace std;
    class point{
    int x ,y ;
    friend void distance(point o1 ,point o2 );
    public:
    point (int a ,int b){
    x=a;
    y=b;
    }
    void display(){
    cout

    • @tmkocfan5135
      @tmkocfan5135 10 месяцев назад +4

      correct one

    • @GOJOANDSUKUNAFAN
      @GOJOANDSUKUNAFAN 6 месяцев назад

      Same code Dalal ni chla nalle

    • @user-sy4ox5ri8p
      @user-sy4ox5ri8p 3 месяца назад

      thanks

    • @kranti9473
      @kranti9473 3 месяца назад +1

      Thank you for the help...
      It really helped a lot..
      May god bless you 🙏

    • @swamisds
      @swamisds 2 месяца назад

      if we want that user should tell us the points, what would be the code changes in int main then ?

  • @user-zg2yn1tb2d
    @user-zg2yn1tb2d Год назад +9

    you are the best teacher sir!
    //code for parametric constructor to find distance between x-coordinate and y-coordinate :
    #include
    #include
    #include
    using namespace std;
    class Point
    {
    int x, y;
    friend void distance(Point, Point);
    public:
    Point(int a, int b)
    {
    x = a;
    y = b;
    }
    void display_point()
    {
    cout

  • @RahulSaini-pp5kz
    @RahulSaini-pp5kz 2 года назад +88

    I did the distance between two poitns all by myself after encountering some errors and i am very happy about it.Thank you very much😭😭😭😭😭😭😭😭😭😭😭😭😭😭

    • @user-ht3zx6oo3j
      @user-ht3zx6oo3j 2 года назад +11

      Rota kahe ko h ye le chocolate kha

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

      @@user-ht3zx6oo3j papi gudiya bhag ja bache ko rulati hai😡
      Rahul bro isse chocolate 🍫 nhi lena

    • @user-ht3zx6oo3j
      @user-ht3zx6oo3j 2 года назад +8

      @@ak689 rahul ko to kabka chocolate 🍫 de diya ab teri baari h chote
      Haahaaahaahaaaa..............

    • @Suraj_2662
      @Suraj_2662 2 года назад +1

      @@user-ht3zx6oo3j om phatt swaha
      bhag ja yaha se👻

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

      @@user-ht3zx6oo3j tere chocolate Dene se kuch nhi hoga bhag yaha se verna ham sab coder bhga bhaga ke mare ge

  • @samarththaker5051
    @samarththaker5051 11 месяцев назад +2

    Distance between 2 points:
    void distance(point p, point q){
    int r = abs(p.x-q.x);
    int s = abs(p.y-q.y);
    float m = sqrt(r*r+s*s);
    cout

  • @sushilasriv19
    @sushilasriv19 2 года назад +62

    The smallest and the easiest way :-
    Function will be like this (Just make this function as a friend in the class) :-
    void distancePoint(Point obj1, Point obj2)
    {
    double dis;
    dis = sqrt(pow((obj2.x - obj1.x), 2) + pow((obj2.y - obj1.y), 2));
    cout

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

      Abe bhai constructor ka use to kiya ni tumne.... 😂
      Aise to sbko pta h aasan h

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

      Bhai point class kaha gyi tere program ki

    • @sumanshrestha8867
      @sumanshrestha8867 2 года назад +1

      Bhai
      displaypoint()
      function kaha hai

  • @bhaskarsaini4369
    @bhaskarsaini4369 2 года назад +232

    // Parameterized Constructor using Friend Function Example :-
    #include
    #include
    using namespace std;
    class point{
    int x,y;
    friend void distance (point , point);
    public:
    point (int a,int b){
    x=a;
    y=b;
    }
    void displayPoint(){
    cout

    • @pranavmaniyar4592
      @pranavmaniyar4592 2 года назад +18

      diff ko int kyu define kiya , double would have been better , isn't it?

    • @ankitjha.23
      @ankitjha.23 2 года назад +3

      😘

    • @AKS-td5iz
      @AKS-td5iz 2 года назад +5

      @@ankitjha.23 mwah mwah baby

    • @curiousritik4558
      @curiousritik4558 2 года назад +5

      Bhai garbage value kyu aari

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

      if you write return type of "diff" variable as float then it will be better.

  • @trendy_takes
    @trendy_takes 2 года назад +13

    Finally Harry Bhai ko "tempcoderunner" wale error ka reason smj aa gya 😅... Btw... He is the best in his field 🙌🏻❤️

  • @Justin_Roy
    @Justin_Roy 3 года назад +7

    Main Logic
    Without Using Friend Function .......
    Public:
    Point(int,int,int,int);
    void Printdata()
    {
    cout

  • @swethachilveri4123
    @swethachilveri4123 4 года назад +281

    // parameterized constructors
    #include
    #include
    using namespace std;
    class point{
    int x;
    int y;
    public :
    friend void difference(point , point);
    point(int a, int b){
    x=a;
    y=b;
    }
    void displaypoint(){
    cout

  • @prateekdhingra292
    @prateekdhingra292 3 года назад +12

    Harry Bhai ekdum mast samajh aa gaya! saare concepts ki complete practice ho gayi.

  • @manavsingh3941
    @manavsingh3941 Год назад +18

    Quiz1:
    Distance b/w 2 Points
    #include
    #include
    using namespace std;
    class point{
    int x, y;
    friend void distance(point, point);
    public:
    point(int a, int b){
    x = a;
    y = b;
    }
    void display(void){
    cout

  • @anju7334
    @anju7334 Год назад +10

    I did it 🙏.
    Firstly I thought that I couldn't do this but I said to myself let's give it a try.
    And Maine kar liya with god's grace.
    Thanku so much sir for providing us immense knowledge for free.
    ❤️

  • @naman1312
    @naman1312 Год назад +13

    Answer to the easy quiz.
    (For those who don't know these functions which I have used, read this then see the answer.)
    To do some basic math operations, we need to import header file .
    sqrt function --> It calculates the square root of a number.
    pow function --> It calculates the exponent of a number. It takes two parameters - the number to be powered and the power which has to be raised to that number.
    The code for the answer to this quiz:
    #include
    #include
    using namespace std;
    class Point{
    int x, y;
    friend float distance(Point, Point);
    public:
    Point(int a, int b){
    x = a;
    y = b;
    }
    void displayPoint(){
    cout

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

      Thanks bro for providing this information😊... By the way you written this code by your own?

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

      @@YashYadvav123 yes

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

      Bro c++ ke notes bna rakhe h pdf file chaiye thi ?

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

      @@jee6455 bhai maine itni mehnat se bnaye hai aise hi kaise dedu

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

      @@naman1312 ohk

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

    First time i did something by myself. It takes little more time but I'm very happy. Thank you harry sir

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

    Program:----
    #include
    #include
    Using namespace std;
    Class point{
    Int x,y;
    Public:
    point(int a,int b){
    x=a;
    y=b; }
    Void display (){
    Cout

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

      Nice

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

      A slight mistake here u put some words capital like Class but it should be class and same with Using,int,court...

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

      @@FANSasFRIENDS bro I know but thing is concept clear hona chahiye syntax error to aaram se theek ho sakta hai

    • @Rohan-ov3fr
      @Rohan-ov3fr 3 года назад +4

      @@prashantmajumdar1519 bro how you done this because I m not able to do this in first attempt So can u guide hiw you can understand his vedio plz bro

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

      @@Rohan-ov3fr bhai itna kuch nahi hai bass consistent raho and maine ye playlist bohot focus rehke follow kia hai to mujhse ho gaya I will suggest you to solve atleast 2-3 coding problem per day to increase your problem solving skill

  • @093_kartikdwivedi3
    @093_kartikdwivedi3 2 года назад +11

    program for getting the distance between two points:-
    //this is a program for getting the distance between two points using constructor and math function
    #include
    #include
    using namespace std;
    class point{
    int x , y;
    public:
    friend int distance(point o1,point o2);
    point(int , int );
    void display(){ // we can define the constructor here also
    cout

    • @ankitsoni6203
      @ankitsoni6203 6 месяцев назад

      #include
      #include
      using namespace std;
      class point{
      int x,y;
      public:
      point(int a, int b){
      x=a;
      y=b;
      }
      void printpoint(){
      cout

  • @nihalpandey5675
    @nihalpandey5675 4 года назад +27

    // Program to calculate the distance between two cartesian points
    #include
    #include
    using namespace std;
    class point
    {
    int a,b;
    public :
    void setvalue (int x,int y)
    {
    a =x; b=y;
    }
    friend int distance (point A,point B);
    };
    int distance (point A,point B)
    {
    float c = sqrt ((A.a- B.a)*(A.a- B.a)+ (A.b- B.b)*(A.b- B.b));
    return c;
    }
    int main()
    {
    int x,y;
    cout > x>>y;
    point C,D;
    C.setvalue (x,y);
    cout > x>>y;
    D.setvalue (x,y);
    int c =distance (C,D);
    cout

  • @anshumankumar1946
    @anshumankumar1946 2 года назад +8

    Distance between two coordinate points:
    #include
    #include
    using namespace std;
    class Point
    {
    int x, y;
    friend int Distance(Point, Point);
    public:
    Point(int a, int b){
    x = a;
    y = b;
    }
    };
    int Distance(Point o1, Point o2){
    int x_diff = (o2.x-o1.x);
    int y_diff = (o2.y-o1.y);
    int diff = sqrt(pow(x_diff,2)+pow(y_diff,2));
    return diff;
    }
    int main(){
    Point p1(1, 1), p2(1,1);
    cout

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

      int diff = sqrt(pow(x_diff,2)+pow(y_diff,2));i
      isme ,2 kyu use kara hai?

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

      @@rahilpanwar5999 kyuki formula me square karte hai
      √((x2-x1)² + (y2-y1)²)
      To pow(xdiff,2) ka matlab wahi hai
      (x2-x1)²

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

    // This program is written by using the concept of friend function, parameterized constructor.
    // This program is valid for any point as it takes point as an input from the user.
    #include
    #include
    using namespace std;
    class point
    {
    private:
    int x;
    int y;
    public:
    friend void distance(point, point);
    point(int a, int b);
    void getpoint(void)
    {
    cout

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

    THANK YOU HARRY BHAIYA FOR MAKING THE CONCEPT EASY.
    CODE:
    #include
    #include
    using namespace std;
    double v;
    class point{
    int a,b;
    public:
    friend class dist;
    void setPoint(int x,int y){
    a=x;
    b=y;
    }
    int displayDistance(point,point);
    };
    class dist{
    public:
    int distance(point,point);
    };
    int dist :: distance(point a1,point a2){
    int diff1=(a1.a-a2.a)*(a1.a-a2.a);
    int diff2=(a1.b-a2.b)*(a1.b-a2.b);
    if (diff1>diff2){
    v=sqrt(diff1-diff2);
    }
    else{
    v=sqrt(diff2-diff1);
    }

    return v;
    }
    int point :: displayDistance(point a1,point a2){
    cout

  • @abhishekrawat8074
    @abhishekrawat8074 Год назад +25

    My code:
    // Exercise question
    // Create a function (hint:make it a friend function) which takes two point objects
    // and computes the distence between those two points
    #include
    #include
    using namespace std;
    class point
    {
    int x, y;
    public:
    friend void distance(point o1, point o2);
    point(int num1, int num2)
    {
    x = num1;
    y = num2;
    }
    void display()
    {
    cout

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

      u should have used float for distance

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

      function overloading makes it more efficient Nice

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

      bro you forget to apply forward declaration.

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

      bhai float distance use kare to perfect value milega

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

    I have used both method 1> just by declaring a function to calculate distance 2> using friend function
    #include
    using namespace std;
    class point{
    int x,y;
    public:
    point(int a,int b){
    x=a;
    y=b;
    }
    // ---> Normally
    // float dis(point p, point q){
    // int ans=pow(abs(p.x - q.x),2) +pow(abs(p.y- q.y),2) ;
    // return pow(ans,0.5);
    // }
    friend float dist(point ,point);
    };
    // using function as friend
    float dist(point p, point q){
    int ans=pow(abs(p.x - q.x),2) +pow(abs(p.y- q.y),2) ;
    return pow(ans,0.5);
    }
    int main(){
    point a(0,0);
    point b(4,3);
    //cout

  • @aryan7069_
    @aryan7069_ 3 года назад +5

    I made that function before you asked to . Also i took point in 3D space.
    float dist(Point p , Point q){
    return pow(pow(p.x - q.x , 2) + pow(p.y - q.y , 2) + pow(p.z - q.z, 2) , 0.5);
    }
    though i used pow lol

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

    quick quiz ans:-
    #include
    #include
    using namespace std;
    class point{
    int x, y;
    friend int distance(point p1 , point p2);
    public:
    point(int a, int b){
    x = a;
    y = b;
    }
    void print_Parameter(void){
    cout

  • @sukhmanpreetsinghsandhub2042
    @sukhmanpreetsinghsandhub2042 3 года назад +10

    great way of explanation i am enjoying them a lot thank you so much

  • @aiexplorations-cv1js
    @aiexplorations-cv1js Год назад +1

    Distance Between two Points :
    #include
    #include
    using namespace std;
    class Complex{
    private :
    double a, b;
    public :
    // Complex(void)); // Default Constructors
    Complex(int , int); // Parametrized Constructors
    void printNumber(){
    cout

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

    The solution for to find the distance between:
    float distence(Points p, Points q){
    float result;
    result = sqrt((((q.x)-(p.x))*((q.x)-(p.x))) + (((q.y)-(p.y))*((q.y)-(p.y))));
    return result;
    }
    This will give the exact value of the distance between points.
    Thank You!

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

    Harry bhai, challenge or quiz accepted, here is my fully-functional code to print distance the two points wherein I have tried to utilise the concepts of parametrised constructor, friend function and even explored some new mathematical functions in the c++ standard cmath library. btw, here is my code:
    #include
    #include
    using namespace std;
    class geometry{
    int x,y;
    public:
    // parametrized function to initailize the value of the variables
    geometry(int a, int b){
    x = a;
    y = b;
    }
    // print_point() : to print the formed point.
    void print_point(){
    cout

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

      My answer 😀 :
      Answer to the easy quiz.
      (For those who don't know these functions which I have used, read this then see the answer.)
      To do some basic math operations, we need to import header file .
      sqrt function --> It calculates the square root of a number.
      pow function --> It calculates the exponent of a number. It takes two parameters - the number to be powered and the power which has to be raised to that number.
      The code for the answer to this quiz:
      #include
      #include
      using namespace std;
      class Point{
      int x, y;
      friend float distance(Point, Point);
      public:
      Point(int a, int b){
      x = a;
      y = b;
      }
      void displayPoint(){
      cout

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

    This video has highest like to dislike ratio(=200) among the videos I have seen on RUclips. Keep it up!

  • @adityapradhan8474
    @adityapradhan8474 8 месяцев назад +1

    Thank you so much harry bhai
    Because of you I am able to understand the concepts of OOPS so easily!

  • @justfun-bn4kt
    @justfun-bn4kt 4 года назад +3

    Aoa bro am pakistani aur ma na c++ learn krna tha aur ma ap ka sary lecture Dako ga aur ma na ap ko subscribe be kr Dia thks bro great effort. May you live long

  • @Tajinder0singh
    @Tajinder0singh 3 месяца назад +1

    12:38
    //! A Slightly Alternate Solution.
    #include
    #include
    #include
    using namespace std;
    //+ Practice Question
    //*Q.Create a function which takes 2 point objects and computes the distance between those 2 points.
    class Point
    {
    private:
    int x , y;
    friend float distanceCalculator(Point , Point);
    friend void diplayPointDistance(Point , Point);
    public:
    Point(int a , int b)
    {
    x = a;
    y = b;
    }
    void displayPoint()
    {
    cout

  • @_TheInquistive
    @_TheInquistive 8 месяцев назад +1

    Now every point is my friend😊
    #include
    #include
    using namespace std;
    class vector
    {
    int x,y;
    public :
    vector(int,int);
    void dis(void);
    friend void distance(vector o1,vector o2);
    };
    vector ::vector(int a,int b)
    {
    x=a;
    y=b;
    }
    void vector::dis(void)
    {
    cout

  • @nishkarshjain5684
    @nishkarshjain5684 4 года назад +9

    Thank u soo much bro...
    Ur videos really helps me... 🥰

  • @Tajinder0singh
    @Tajinder0singh 3 месяца назад +1

    12:38
    #include
    #include
    #include
    using namespace std;
    //+ Practice Question
    //*Q.Create a function which takes 2 point objects and computes the distance between those 2 points.
    class Point;
    class Calculator
    {
    private:
    public:
    float distanceBwPoints(Point , Point);
    };
    class Point
    {
    private:
    int x , y;
    friend float Calculator ::distanceBwPoints(Point , Point);
    public:
    Point(int a , int b)
    {
    x = a;
    y = b;
    }
    void displayPoint()
    {
    cout

  • @anuvanshkshatriya7268
    @anuvanshkshatriya7268 Год назад +8

    //finding distance between two points using friend function
    #include
    #include
    using namespace std;
    class Point
    {
    int x, y;
    public:
    Point(int a, int b){
    x = a;
    y = b;
    }
    void displayPts(){
    cout

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

      Ya same program letus C book mai bhi hai

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

      @@satender1616 bhai pr meine toh khud hi code kra hai ,baki ap us book mei se krlo agr same hai toh

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

    // create a function which takes two point object and computes the distance between those two points
    // Hint: make it a friend function
    #include
    #include
    using namespace std;
    class point
    {
    int x;
    int y;
    public:
    point(int, int);
    friend void distance(point a, point b);
    };
    point::point(int u, int v)
    {
    x = u;
    y = v;
    }
    void distance(point a, point b)
    {
    int n1 = (b.x - a.x);
    int n2 = (b.y - a.y);
    cout

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

    Harry bhai sab tutorial mein ek ek single example add kar do n bahut bahut meharbaani hogi aise aap jitna diye wahi main repeat karke dekhunga ho jayega

  • @animeboii-zv8vo
    @animeboii-zv8vo 3 года назад +10

    Thank you sir for this amazing and easy lecture

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

    float distance (point m,point n)
    {
    float z=sqrt ((n.x-m.x)*(n.x-m.x)+(n.y-m.y)*(n.y-m.y)
    Cout

  • @arpitmaurya5849
    @arpitmaurya5849 12 дней назад +1

    #include
    using namespace std;
    class point{
    int x1 ,x2, y1, y2;
    public:
    point(int a, int b ,int c ,int d ){
    x1 = a;
    y1 = b;
    x2 = c;
    y2 = d;
    }
    void displayPoint(){
    cout

  • @strein6502
    @strein6502 3 года назад +7

    you are great bro, Thanks vai for this tutoring , It helps me very much

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

    Sir, I think I did it, bdi mehnat lgi but done. Thanks a lot abhi tk itni saari chizein is playlist ke through sikhaane ke liye.

  • @anti-bug
    @anti-bug 2 года назад +3

    The answer of quiz -->
    #include
    #include
    using namespace std;
    class Point{
    int x, y;
    friend int distance(Point, Point);
    public:
    Point(int a, int b){
    x = a;
    y = b;
    }
    void displayPoint(void){
    cout

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

      Bhai boht mast code hai 😍👍

  • @MuhammadRiyan-wn8wu
    @MuhammadRiyan-wn8wu 6 месяцев назад

    #include
    #include
    using namespace std;
    class quiz{
    int a,b;
    public:
    void give( int x ,int y ){
    a=x;
    b=y;
    }
    friend void diff(quiz,quiz);
    };
    void diff(quiz o1, quiz o2){
    int c,d;
    c=(o2.a-o1.a)*(o2.a-o1.a);
    d=(o2.b-o1.b)*(o2.b-o1.b);
    cout

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

    Thanks

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

    #include
    #include
    using namespace std;
    // Create a function that takes two objects and computes the distance between those 2 points
    // Friend function and maths(sqrt function) library need to be used.
    // TO check the code
    // Distance between (1,1) and (1,1) is 0
    // Distance between (0,1) and (0,6) is 5
    // Distance between (1,0) and (70,0) is 69
    // Distance between (-1,1) and (-1,15) is 14
    class points
    {
    int x, y;
    friend void distance(points o1, points o2);
    public:
    points(int a, int b)
    {
    x = a;
    y = b;
    }
    void printPoints()
    {
    cout

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

    I think friend function ki zaroorat nahi hai:
    // a member function to compute the distance between two poins
    double computeDistance(Point new_point)
    {
    double d;
    d = sqrt(pow((Point::x - new_point.x), 2) + pow((Point::y - new_point.y), 2));
    return d;
    }
    int main()
    {
    // driver program
    Point p(1, 1);
    p.displayPoint();
    Point q(4, 6);
    q.displayPoint();
    cout

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

      I didn't understand that -->"d = sqrt(pow((Point::x - new_point.x), 2) + pow((Point::y - new_point.y), 2)); ".
      What does that *Point::x - new_point.x* means?

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

      @@kushal6065 we are computing Euclidean distance...which means square root of sum of squares of component wise subtraction

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

    #include
    using namespace std;
    #include
    int square(int a){return a*a;}
    class point; float distance(point,point);//declare
    class point{
    int x,y;
    public:
    friend float distance(point,point);
    point(){
    cin>>x>>y;
    }
    };
    float distance(point p,point q){return(sqrt((square((p.x)-(q.x)))+square((p.y)-(q.y))));}
    int main(){point p,q;float c=distance(p,q);cout

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

    Hello harry vai,
    I am from Nepal . It has been all most 2-3 weeks learning python from your python playlist . The project that you have done are very appreciable,hands off for that but you have missed an important project of python and i.e. Face recognition system . I hope you will make an tutorial video for it . And thanks for sharing your knowledge and experience with us .....
    God Bless you .

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

      yes I support

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

      Heyy budd, tell your pm oli that
      He is gonna destroy your country

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

      @@mukeshkashyap1279
      Are you learning programming to discuss these shit things on the comments section .
      As my observations, oli keeps vomiting shits from his mouth on International topics which every Nepali knows, BUT inside the country there has been a lot of developmental in his governance .

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

      @@mukeshkashyap1279 STFU

  • @shubhrai5385
    @shubhrai5385 2 года назад +5

    it's interesting to see how video by video views are decreasing...lol ...only serious people left...dammm

  • @EarthMarvels44
    @EarthMarvels44 2 года назад +1

    int finddistance(point a, point b){
    int res = sqrt(pow((a.x-b.x),2)+pow((a.y-b.y),2));
    return res;
    }

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

    /*
    Create a function which takes 2 point objects and computes the distance between those points
    */
    #include
    #include
    using namespace std;
    class Point{
    int x,y; // Private members
    // Making distanceBetweenPoints as a friend of class Point. So, that we can access the private members of the class Point.
    friend double distanceBetweenPoints(Point,Point);
    public:
    // Default constructor
    Point(void){
    x = 0;
    y = 0;
    }
    // Parameterized Constructor
    Point(int a, int b){
    x = a;
    y = b;
    }
    // Function declaration
    double distanceBetweenPoints(Point , Point );
    void displayPoint(){
    cout

    • @life-oh1bc
      @life-oh1bc Год назад +1

      I like your spacious way of writing code

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

    my code --->
    #include
    #include
    #include
    using namespace std;
    class point;
    class calculator {
    public:
    void distance(point, point);
    };
    class point {
    int x, y;
    public:
    friend class calculator;
    point(int a, int b) {
    x = a;
    y = b;
    cout

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

    12:19
    //More examples of Parameterised Constructors
    #include
    #include
    using namespace std;
    class Point{
    int x, y;
    friend float distance(Point, Point);
    public:
    Point(int a, int b){
    x = a;
    y = b;
    }
    void pointDisplay(){
    cout

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

    //quiz - a function which takes two points and computes the distance between
    //make it a friend function
    //following program doesn't need constructor
    #include
    #include
    using namespace std;
    class point
    {
    int a;
    int b;
    friend float distance(point , point);
    public:
    void coordinate(){

    cout

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

    Hi Harry Bhai.......... Thank you so much .....I'm in class 8 but coding mein bahut interest hai.......ek bar khatam ho Jaye phir dhammal mach jaye

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

      Mcha Di dhmaal phir

    • @a.nmolll
      @a.nmolll 3 года назад +1

      iam in nursery...iam also very interested in coding ...dhamkal mcha denge

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

      I have born today just 368584744351799....micro second ago..... I am also very interested in coding....dhamaal macha denge.

    • @amitsingh-yk3ps
      @amitsingh-yk3ps 2 года назад +1

      im have just died abhi 4 th dimension me hu,i am also very interested ek baar janam lelu phir dhamal macha denge

  • @krishmehta5418
    @krishmehta5418 4 года назад +7

    project completed succesfully

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

    code to pass values in a parametrised constructor, subsequently printing the formed complex number as per the code:
    code:
    #include
    using namespace std;
    // class complex : handles the complex numbers.
    class complex {
    int a,b;
    public:
    complex(int x, int y){
    a=x;
    b=y;
    }
    void print(){
    cout

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

    My code is correct and I can't believe it

  • @LoneWolf2104
    @LoneWolf2104 11 месяцев назад

    int main(){
    Complex c1, c2, sum;
    c1.setNumber(1, 4);
    c1.printNumber();
    c2.setNumber(5, 8);
    c2.printNumber();
    sum = sumComplex(c1, c2);
    sum.printNumber();
    return 0;
    }

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

    best tutorial on C++

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

    // Quiz - take 2 point objects and calculate the distance between them
    #include
    #include
    using namespace std;
    class point
    {
    int a, b;
    public:
    point(int x, int y);
    void printpoint()
    {
    cout

  • @dhruvjain2874
    @dhruvjain2874 2 года назад +16

    /* Author : Dhruv Jain
    Date : 26-06-2022
    */
    // Create a function (HINT : Make it a friend function) which takes 2 point objects and compute the distance between those 2 points
    #include
    #include
    using namespace std;
    class Point
    {
    int x, y;
    // friend Point dispoint(Point, Point);
    public:
    Point();
    Point(int a, int b)
    {
    x = a;
    y = b;
    }
    void printPoint()
    {
    cout

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

    Distance_between_two_points
    Easy Method :
    #include
    #include
    using namespace std;
    class point
    {
    int x, y;
    friend void distance_between_two_points(point, point);
    public:
    point(int a, int b)
    {
    x = a;
    y = b;
    }
    void DisplayPoints()
    {
    printf("The point is (%d + %d)
    ", x, y);
    }
    };
    void distance_between_two_points(point p, point q)
    {
    double distance = sqrt((pow((q.x - p.x), 2)) + (pow((q.y - p.y), 2)));
    cout

  • @shivafoods007
    @shivafoods007 Год назад +2

    // create a function which takes 2 point objects and computes the distance between 2 points.
    #include
    #include
    using namespace std;
    class point
    {
    int x, y;
    friend void pointDifference(point a1, point b1); // friend function declaration
    public:
    point(int a, int b)
    {
    x = a;
    y = b;
    }
    };
    void pointDifference(point a1, point b1)
    {
    int a2 = b1.x - a1.x; // subtracting x points
    int b2 = b1.y - a1.y; // subtracting y points
    int a3 = a2 * a2; // squaring x points
    int b3 = b2 * b2; // squaring y points
    float res = sqrt(a3 + b3); // adding x and y points
    cout

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

    first bhai heart dedo.. Python playlist complete hone wali h

  • @Tojasv
    @Tojasv 2 месяца назад

    //Creating a function which takes 2 point objects and computes the distance between thoe 2 points:
    //(Hint: Make it friend function)
    #include
    #include
    using namespace std;
    class Point{
    int x,y;
    friend void distancePoints(Point o1, Point o2);
    public:
    Point(int a, int b){
    x = a;
    y = b;
    }
    void displayPoint(){
    cout

  • @thesportsman3122
    @thesportsman3122 4 года назад +10

    Hello, I'm from Pakistan.
    I have 2 Questions..
    1. Python k hawaly se kafi videos YT per uoload hain, jin may aap ka bhi kafi contribution hay, sub coding sekhatay hain Laken abhi tak kisi ne nahi bataya keh jub hum coding ker k Koey program bana daitay hain, tho os KA .exe file kaisay banatay hain, our doosray computer may kaisay apnay software ya Program ko install karay.
    2.kia aap Koey aisa program, software, vba, excel sheet, bana saktay hain jis may hum kuch data enter karay our wo Autocad may draw ya plot ho jaey..
    Kafi programmers ko msg our comment kia but abhi tak kisi ne reply nahi kia. Shayad aap bhi aisa na ker sako... ❤️

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

    #include
    using namespace std;
    class sum{
    int a, b;
    public:
    sum(int x ,int y){
    //object name is goven while creating object
    a=x;
    b=y;
    cout

  • @JOYDIPMANNA-fr6op
    @JOYDIPMANNA-fr6op 3 года назад +3

    Your coding skills improve my skills

  • @ayushmishra360
    @ayushmishra360 3 месяца назад +1

    This can be done without including cmath file, we can make use of babylonians method for sqrt

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

    // Create a function which takes two points objects and compute the pointe between those points
    #include
    #include
    using namespace std;
    class pointe{
    private:
    int x;
    int y;
    public:
    friend float pointe_compute(pointe e1,pointe e2);
    pointe(int x1,int y1){
    x=x1;
    y=y1;
    }
    };
    float pointe_compute(pointe e1,pointe e2){
    int x1=e1.x;int x2=e2.x;int y1=e1.y;int y2=e2.y;
    float sub1=pow(x2-x1,2);
    float sub2=pow(y2-y1,2);
    float fin1=sqrt(sub1+sub2);
    return fin1;
    }
    int main(){
    pointe r1(1,3);
    pointe r2(7,6);
    float a=pointe_compute(r1,r2);
    cout

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

      can we dont directly use function inside the class instead of using friend function

  • @ronakmaniya2005
    @ronakmaniya2005 3 месяца назад +1

    The full program is:
    #include
    #include
    using namespace std;
    class Point{
    int x, y;
    friend void computeDistance(Point p1, Point p2);
    public:
    Point(void){ // Default Constructor
    x = 0;
    y = 0;
    }
    Point(int a, int b){ // Parameterized Constructor
    x = a;
    y = b;
    }
    void displayPoint(){
    cout

  • @SahilKumar-ni7su
    @SahilKumar-ni7su 4 года назад +50

    10:30 interent mera aa nhi rha hai mai game khelunga lol :)

    • @MdSalim-yj2gl
      @MdSalim-yj2gl 3 года назад

      Isi comment k liye to vdo pause kr k aaya hu xD

  • @PerfectCapture77
    @PerfectCapture77 6 месяцев назад +1

    #include
    #include
    using namespace std;
    //main class
    class point{
    int x,y;
    friend void distance(point r, point s);
    public:
    point(int a, int b){
    x=a;
    y=b;
    }
    };
    void distance(point r,point s){
    float dis=sqrt(pow(s.x-r.x,2)+pow(s.y-r.y,2));
    cout

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

    Harry bhai always best👍💯 💞

  • @avirupdas3537
    @avirupdas3537 2 месяца назад +1

    //create a function which takes two point objects and computes the distance between those two points
    //Hint :make it a friend function
    #include
    #include
    using namespace std;
    class Point
    {
    int x, y;
    public:
    friend void distance_points(Point a, Point b);
    Point(int a, int b)
    {
    x = a;
    y = b;
    }
    void displayPoint()
    {
    cout

  • @mhassaan1226
    @mhassaan1226 4 года назад +13

    #include
    #include
    using namespace std;
    class Point
    {
    int x, y;
    friend Point computes(Point o1, Point o2);
    public:
    Point(int a, int b)
    {
    x = a;
    y = b;
    }
    void displayPoint()
    {
    cout

    • @aadityaa.
      @aadityaa. 2 года назад

      Well done bro...Thank you. It helps me a lot..🤗!

  • @shubhamlala1873
    @shubhamlala1873 2 года назад +1

    solution of question---
    #include
    #include
    using namespace std;
    class point{
    int a,b;
    friend void distance(point o1, point o2);
    public:
    point(int x , int y);
    void display(void){
    cout

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

    Can u suggest me a laptop for programming and further use android development and for after effects .

  • @vedant_tathe
    @vedant_tathe 2 года назад +1

    Quiz Answer :
    #include
    #include
    using namespace std;
    class point
    {
    int x,y;
    public:
    void setdata (int i,int j)
    {
    x=i;
    y=j;
    }
    friend float dis (point, point);
    } ;
    float dis (point a, point b)
    {
    float d = sqrt( pow((b.x-a.x),2) + pow((b.y-a.y),2));
    return d;
    }
    int main ()
    {
    point a;
    point b;
    a. setdata (1,1);
    b. setdata (2,3);
    float d = dis (a, b);
    cout

  • @CoderVroni
    @CoderVroni 3 года назад +12

    You were making this video on 11 march 2020, haven't you played holi?😂😅

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

      He probably had completed the video before holi✌️

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

      Dedication level for programming ❣

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

    // by taking inputs from user calulating distance between two points.
    #include
    #include
    using namespace std;
    class input //taking inputs from users
    {
    int x1;
    int x2;
    int y1;
    int y2;
    friend void distance(input );
    public:
    input()
    {
    couty1;
    couty2;
    }
    };
    void distance(input a1)
    {

    float pdiffx=pow((a1.x2-a1.x1),2);
    float pdiffy=pow((a1.y2-a1.y1),2);
    float tdis=sqrt(pdiffx+pdiffy);
    cout

  • @RohanDasRD
    @RohanDasRD 4 года назад +7

    Kal se boards start hai mera.. to bhai ye 28th tak channel pe active nahi reh paunga bhai. Uske baad dhoom machaunga♥️

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

      Rohan das ...sir ka bhai h kya?????????

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

      @@anoopkumarshukla6808 no, but he is active viewer who is connected form the very starting with harry bhaii

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

    #include
    #include
    using namespace std;
    class point
    {
    int x, y;
    friend float distance(point p1, point p2);
    public:
    point(int a, int b)
    {
    x = a;
    y = b;
    }
    };
    float distance(point p1, point p2)
    {
    float s = sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
    return s;
    }
    int main()
    {
    point p1(12, 15);//implicit call
    point p2(0, 5);
    cout

  • @RohanKumar-hw4vy
    @RohanKumar-hw4vy 4 года назад +4

    #include
    #include
    using namespace std;
    class Point
    {
    private:
    int x;
    int y;
    public:
    Point(int a , int b);
    friend int distance(Point pt1 , Point pt2);
    void display(void){
    cout

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

    #include
    #include
    using namespace std;
    class Distance{
    int x,y;
    public:
    Distance(int a ,int b);
    void display(){
    cout

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

    Assalamualaikum, Harry Bhai
    Bhai aap ek konsa CPU lena best programming ke liye aur Gaming ke liye aur youtube purpose live streaming ke liye pls Isper ek video na bhai....

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

      minimum i3 processor ke sath 4gb ram

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

      Quad core i5 with 8 gb ram + 2-4 gb GPU or AMD ryzen r5 with 8 gb ram + 2-4 gb GPU.

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

    first we want to include the heterofile(#include)
    double distanceTo(point otherPoint)
    {
    return sqrt(pow(otherPoint.x - x, 2) + pow(otherPoint.y - y, 2));
    }

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

    11:59 yahan pe ye kyu ro raha hai ...xD lol

  • @kfitness4386
    @kfitness4386 2 месяца назад

    // Q.) create a function(hint : make it a friend function) which takes 2 objects and computes the distance between thode points
    #include
    #include
    using namespace std;
    class point{
    int x, y;
    friend void distance(point o1, point o2);
    public:
    point( int a, int b){
    x = a;
    y = b;
    }
    void display(){
    cout

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

    Sir please post the solution of the quiz you gave us 🙏🏻

  • @himanshu_7921
    @himanshu_7921 4 месяца назад

    Edit: Quiz from My side:-
    Take position co-ordinates of 2 point objects and Calculate Force Acting b/w these objects..
    Google : Formula for Force b/w 2 point masses in 2D sapce..
    12:30 Solution of this Quiz....
    #include
    #include
    using namespace std;
    //Example of Constructor: Calculate distance between 2 Points in 2D space...
    class Point
    {
    private:
    int x,y;
    friend void Calculate_Distance_Between_Points (Point object_1, Point object_2); //Friend Function
    public:
    Point (int a, int b) //Parameterized Constructor
    {
    x=a;
    y=b;
    }
    void Display_Point_1()
    {
    cout

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

    When you will give solution of your question

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

    Solution for the distance between two points:-
    #include
    #include
    using namespace std;
    class point{
    int x,y;
    friend void distance(point, point);
    public:
    point(int a, int b){
    x = a;
    y = b;
    }
    void print(){
    cout

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

    C++ Vs Java for competitive programming?

  • @musabkhan6160
    @musabkhan6160 2 года назад +1

    Solving quiz with taking user input :-
    #include
    #include
    using namespace std;
    class m
    {
    int x1,x2;
    int y1,y2;
    public:
    phone(int, int, int , int);
    };
    phone::phone(int a, int b,int c, int d)
    {
    x1 = a;
    y1 = b;
    x2 = c;
    y2 = d;
    }
    float distance(int x1,int y1,int x2, int y2){
    float res;
    res = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    return res;
    }
    int main()
    {
    int x1,x2,y1,y2;
    cout x1 >> y1;

    cout x2 >> y2;
    phone p1(x1,y1,x2,y2);
    float i = distance(x1,y1,x2,y2);
    cout

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

    #include
    #include ;
    using namespace std;
    class complex
    {
    int x, y;

    friend float distance(complex, complex );

    public:

    complex(int ,int );
    void printNumber(void)
    {
    cout

  • @bugsfounder
    @bugsfounder 2 года назад +1

    float distance(Point o1, Point o2)
    {
    float d = sqrt(pow(o2.x - o1.x, 2) + pow(o2.y - o1.y, 2));
    return d;
    }