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
//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
correct one
Same code Dalal ni chla nalle
thanks
Thank you for the help...
It really helped a lot..
May god bless you 🙏
if we want that user should tell us the points, what would be the code changes in int main then ?
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
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😭😭😭😭😭😭😭😭😭😭😭😭😭😭
Rota kahe ko h ye le chocolate kha
@@user-ht3zx6oo3j papi gudiya bhag ja bache ko rulati hai😡
Rahul bro isse chocolate 🍫 nhi lena
@@ak689 rahul ko to kabka chocolate 🍫 de diya ab teri baari h chote
Haahaaahaahaaaa..............
@@user-ht3zx6oo3j om phatt swaha
bhag ja yaha se👻
@@user-ht3zx6oo3j tere chocolate Dene se kuch nhi hoga bhag yaha se verna ham sab coder bhga bhaga ke mare ge
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
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
Abe bhai constructor ka use to kiya ni tumne.... 😂
Aise to sbko pta h aasan h
Bhai point class kaha gyi tere program ki
Bhai
displaypoint()
function kaha hai
// 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
diff ko int kyu define kiya , double would have been better , isn't it?
😘
@@ankitjha.23 mwah mwah baby
Bhai garbage value kyu aari
if you write return type of "diff" variable as float then it will be better.
Finally Harry Bhai ko "tempcoderunner" wale error ka reason smj aa gya 😅... Btw... He is the best in his field 🙌🏻❤️
Main Logic
Without Using Friend Function .......
Public:
Point(int,int,int,int);
void Printdata()
{
cout
// 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
Thanks for the code
Thanks
instead of multiplying twice for square you can use pow() fuction in .
@@harshvardhanbajpai7846 yas
cout
Harry Bhai ekdum mast samajh aa gaya! saare concepts ki complete practice ho gayi.
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
Nice brother
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.
❤️
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
Thanks bro for providing this information😊... By the way you written this code by your own?
@@YashYadvav123 yes
Bro c++ ke notes bna rakhe h pdf file chaiye thi ?
@@jee6455 bhai maine itni mehnat se bnaye hai aise hi kaise dedu
@@naman1312 ohk
First time i did something by myself. It takes little more time but I'm very happy. Thank you harry sir
Program:----
#include
#include
Using namespace std;
Class point{
Int x,y;
Public:
point(int a,int b){
x=a;
y=b; }
Void display (){
Cout
Nice
A slight mistake here u put some words capital like Class but it should be class and same with Using,int,court...
@@FANSasFRIENDS bro I know but thing is concept clear hona chahiye syntax error to aaram se theek ho sakta hai
@@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
@@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
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
#include
#include
using namespace std;
class point{
int x,y;
public:
point(int a, int b){
x=a;
y=b;
}
void printpoint(){
cout
// 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
Bro your return type of distance should be float
graaappppeeeeee
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
int diff = sqrt(pow(x_diff,2)+pow(y_diff,2));i
isme ,2 kyu use kara hai?
@@rahilpanwar5999 kyuki formula me square karte hai
√((x2-x1)² + (y2-y1)²)
To pow(xdiff,2) ka matlab wahi hai
(x2-x1)²
// 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
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
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
u should have used float for distance
function overloading makes it more efficient Nice
bro you forget to apply forward declaration.
bhai float distance use kare to perfect value milega
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
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
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
great way of explanation i am enjoying them a lot thank you so much
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
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!
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
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
This video has highest like to dislike ratio(=200) among the videos I have seen on RUclips. Keep it up!
Thank you so much harry bhai
Because of you I am able to understand the concepts of OOPS so easily!
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
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
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
Thank u soo much bro...
Ur videos really helps me... 🥰
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
//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
Ya same program letus C book mai bhi hai
@@satender1616 bhai pr meine toh khud hi code kra hai ,baki ap us book mei se krlo agr same hai toh
// 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
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
Thank you sir for this amazing and easy lecture
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
#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
you are great bro, Thanks vai for this tutoring , It helps me very much
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.
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
Bhai boht mast code hai 😍👍
#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
Thanks
#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
which year(college)?
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
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?
@@kushal6065 we are computing Euclidean distance...which means square root of sum of squares of component wise subtraction
#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
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 .
yes I support
Heyy budd, tell your pm oli that
He is gonna destroy your country
@@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 .
@@mukeshkashyap1279 STFU
it's interesting to see how video by video views are decreasing...lol ...only serious people left...dammm
int finddistance(point a, point b){
int res = sqrt(pow((a.x-b.x),2)+pow((a.y-b.y),2));
return res;
}
/*
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
I like your spacious way of writing code
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
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
//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
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
Mcha Di dhmaal phir
iam in nursery...iam also very interested in coding ...dhamkal mcha denge
I have born today just 368584744351799....micro second ago..... I am also very interested in coding....dhamaal macha denge.
im have just died abhi 4 th dimension me hu,i am also very interested ek baar janam lelu phir dhamal macha denge
project completed succesfully
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
My code is correct and I can't believe it
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;
}
best tutorial on C++
// 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
/* 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
Very helpful bro
👍🏻 thanks
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
// 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
first bhai heart dedo.. Python playlist complete hone wali h
//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
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... ❤️
#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
Your coding skills improve my skills
This can be done without including cmath file, we can make use of babylonians method for sqrt
// 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
can we dont directly use function inside the class instead of using friend function
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
10:30 interent mera aa nhi rha hai mai game khelunga lol :)
Isi comment k liye to vdo pause kr k aaya hu xD
#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
Harry bhai always best👍💯 💞
//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
#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
Well done bro...Thank you. It helps me a lot..🤗!
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
Can u suggest me a laptop for programming and further use android development and for after effects .
price range?????
My suggestion is only for pc setup.
@@karanpreet_8174 20000 - 25000
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
You were making this video on 11 march 2020, haven't you played holi?😂😅
He probably had completed the video before holi✌️
Dedication level for programming ❣
// 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
Kal se boards start hai mera.. to bhai ye 28th tak channel pe active nahi reh paunga bhai. Uske baad dhoom machaunga♥️
Rohan das ...sir ka bhai h kya?????????
@@anoopkumarshukla6808 no, but he is active viewer who is connected form the very starting with harry bhaii
#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
#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
#include
#include
using namespace std;
class Distance{
int x,y;
public:
Distance(int a ,int b);
void display(){
cout
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....
minimum i3 processor ke sath 4gb ram
Quad core i5 with 8 gb ram + 2-4 gb GPU or AMD ryzen r5 with 8 gb ram + 2-4 gb GPU.
first we want to include the heterofile(#include)
double distanceTo(point otherPoint)
{
return sqrt(pow(otherPoint.x - x, 2) + pow(otherPoint.y - y, 2));
}
11:59 yahan pe ye kyu ro raha hai ...xD lol
// 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
Sir please post the solution of the quiz you gave us 🙏🏻
You want the answer of this quiz
@@HarmonyExplorer yes bro
??????
@@HarmonyExplorer Yess bro plz plz send me I am stuck on that for more than an hour
Output k sath
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
When you will give solution of your question
I have answer...
@@saquibkhan2107 yha post kr bhai
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
C++ Vs Java for competitive programming?
C++ obvious
C++ because java is heavy
And compilation of codes in c++ is more faster than java
C++ because it's syntax is shorter than java it is faster than java
lol obviously C++
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
#include
#include ;
using namespace std;
class complex
{
int x, y;
friend float distance(complex, complex );
public:
complex(int ,int );
void printNumber(void)
{
cout
float distance(Point o1, Point o2)
{
float d = sqrt(pow(o2.x - o1.x, 2) + pow(o2.y - o1.y, 2));
return d;
}