Need some help for class

Hi, i am trying to do my homework, here is the question.
1.Write a program using classes that will add and subtract polynomials.
2. create a menu will allow the user to select either to add or to subtract two polynomials

I have no idea why I can't put any value in the selection.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <iostream>


using namespace std;

class Polynomials
{
	private :
		int a,b,c,d;
		
	public:
	    
	    Polynomials();
	    void set_coff_add();
	    void set_coff_sub();
		void print_value();

};

Polynomials::Polynomials()
{
	a=2;b=4;c=6;d=8;
	
}


void Polynomials::set_coff_add()
{
	int A,B,C,D,E,F,G,H;
	
	cout<<"Set up the first set of number you want to add: "<<endl;
	cin>>A>>B>>C>>D;
	cout<<"Enter the second set "<<endl;
	cin>>E>>F>>G>>H;
	a=A+E;
	b=B+F;
	c=C+G;
	d=D+H;
}


void Polynomials::set_coff_sub()
{
	int A,B,C,D,E,F,G,H;
	
	cout<<"Set up the first set number you want to subtract: "<<endl;
	cin>>A>>B>>C>>D;
	cout<<"Enter the second set "<<endl;
	cin>>E>>F>>G>>H;
	a=A-E;
	b=B-F;
	c=C-G;
	d=D-H;
}

void Polynomials::print_value()
{
    cout<<a<<"x^3 "<<b<<"x^2 "<<c<<"x "<<d<<endl;
}

class object
{
	public:
		Polynomials P;
	public:
		int select();
};

int object::select()
{
	int answer;
	cout<<"Enter 0 for add 1 for subtract: "<<endl;
	cin>>answer;
	if(answer==0)
	{
        P.set_coff_add();
		P.print_value();
	}
	if(answer==1)
	{
	    P.set_coff_sub();
	    P.print_value();
	}

}

int main()
{
	object choice;
	choice.select();
}


I have no idea why I can't put any value in the selection.

I don't know what you mean by that.

Your code works for me:
1
2
3
4
5
6
7
8
Enter 0 for add 1 for subtract:
0
Set up the first set of number you want to a
1 2 3 4
Enter the second set
5 6 7 8
6x^3 8x^2 10x 12
Press any key to continue . . .
Topic archived. No new replies allowed.