/*
write a c++ program to define a class for 3 dimensional points. write necessary member function
for accepting and the point object overload the following
operator
operator example purpose
+(Binary) p3=p1+p2 multiplies coordinate of point p1 with p2
-(Binary) p3=p2-p1; substract coordinates p1 from p2
*/
#include<iostream.h>
#include<conio.h>
#include<string.h>
int i=0;
class binary
{
int p;
public:void accept()
{
i=i+1;
cout<<"enter the dimentional point "<<i<<":-";
cin>>p;
}
void operator *(binary p2)
{
int ans;
ans=p*p2.p;
cout<<"\nmultiplication of two cordinate point:-"<<ans;
}
void operator -(binary p2)
{
int ans;
ans=p-p2.p;
cout<<"\nsubstraction of two coordinaates point:-"<<ans;
}
};
int main()
{
binary p1,p2;
clrscr();
p1.accept();
p2.accept();
p1*p2;
p1-p2;
getch();
return 0;
}
/*
enter the dimentional point 1:-3
enter the dimentional point 2:-4
multiplication of two cordinate point:-12
substraction of two coordinaates point:--1
*/
write a c++ program to define a class for 3 dimensional points. write necessary member function
for accepting and the point object overload the following
operator
operator example purpose
+(Binary) p3=p1+p2 multiplies coordinate of point p1 with p2
-(Binary) p3=p2-p1; substract coordinates p1 from p2
*/
#include<iostream.h>
#include<conio.h>
#include<string.h>
int i=0;
class binary
{
int p;
public:void accept()
{
i=i+1;
cout<<"enter the dimentional point "<<i<<":-";
cin>>p;
}
void operator *(binary p2)
{
int ans;
ans=p*p2.p;
cout<<"\nmultiplication of two cordinate point:-"<<ans;
}
void operator -(binary p2)
{
int ans;
ans=p-p2.p;
cout<<"\nsubstraction of two coordinaates point:-"<<ans;
}
};
int main()
{
binary p1,p2;
clrscr();
p1.accept();
p2.accept();
p1*p2;
p1-p2;
getch();
return 0;
}
/*
enter the dimentional point 1:-3
enter the dimentional point 2:-4
multiplication of two cordinate point:-12
substraction of two coordinaates point:--1
*/
No comments:
Post a Comment