Didn't look through all of it, might edit more later.
First thing I see:
1 2 3 4 5 6
|
Prog1::Prog1(int a, int b, string type){
a = _a;
b = _b;
type = _type;
input(a, b, type);
}
|
You're doing it backwards. You are assigning the value of _a to a, where "a" is the parameter of your constructor. _a is uninitialized at this point. Same for the others.
Do this:
1 2 3 4 5
|
Prog1::Prog1(int a, int b, string type){
this->_a = a;
this->_b = b;
this->_type = type;
}
|
Note that the "this->" prefix is not needed in this case, if the member name is different than the parameter name.
Your input() member function doesn't make a lot of sentence either, due to a similar confusion. "a" is just the parameter of the function, and has nothing to with your _a member function. When you do
cin, this isn't being saved.
Instead of your input() function, I would rather have a default constructor that then asks you to fill in _a and _b.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
Prog1::Prog1()
{
int a_temp;
int b_temp;
std::string type_temp;
cin >> a_temp;
_a = a_temp;
cin >> b_temp;
_b = b_temp;
cin >> type_temp;
_type = type_temp;
}
|
----------------------------------
Other edit:
If the code is set up in the way described above,
1 2 3
|
case 1:
Prog1 prog1(); //first program is run in this case, a simple calculator
break;
|
should not actually execute anything other than the
default constructor (which you didn't previously have!!) itself.
You would want to something like:
1 2 3 4
|
case 1:
Prog1 prog1(); //first program is run in this case, a simple calculator
prog1.eqType(); //not sure if this is what you want, but it would be like "running" the program once you created it
break;
|