/*
I made point class it has two objct x,y. i made saparate function for giving
values to x & y object but when i run the it provide wrong answer.
i enter firstValue=5 , secondVaue=6. the program shoul provide same answer same
as like(5,6) but result show after excuting is wrong . what was wrong with this.
*/
#include<iostream.h>
class point
{
private :
int x,y;
public :
void init(int u ,int v)
{
x=u;y=v;
}
void set();
void print();
};
void point :: print()
{
cout<<"("<<x<<","<<y<<")";
}
void point ::set()
{
point p; int p1,p2;
cout<<"Enter the first no # ";
cin>> p1;
cout<<"Enter the second no # ";
cin>>p2;
p.init(p1,p2); // we enter p.init(5,6);
}
int main()
{
point p;
p.set();
p.print();
return 0;
}
HASHMI007
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
HASHMI007
Fbody 682 Posting Maven Featured Poster
HASHMI007
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.