class program

hi
i am trying to run this prog. on classes but the compiler is showing error in line 33.---i am not able to get that
plz help



/*1. Make a class called "point" with two integer data members x and
y. Show how to create and use two points p1 and p2.*/

#include <iostream>

using namespace std;

class point
{
public:
int x;
int y;
int sum(int,int);
};

int point::sum(int a,int b)
{
cout << "enter any 2 integers";
cin >> a >> b;
x = a;
y = b;

return(x+y);
}

int main()
{
int s;

point D;

s = D.sum(int a,int b); //this is error line

cout<<s;

return 0;
}

I see a lot of people load up code in a message like you do. Try to use # (under format), thats easier to read

You cant declare a variable at the moment you use them as parameters. Change your code in someting like this and the problem is solved:
1
2
3
4
point D;
int a=1;  //declaring variables
int b=2;
s = D.sum(a,b);

Topic archived. No new replies allowed.