1) Please use code tags when posting code, to make it readable.
http://www.cplusplus.com/articles/z13hAqkS/
2) You haven't actually told us what the problem is. We're not mind-readers. The more information you give us, the easier it will be for us to find the problem.
Do you have compiler errors? Linker errors? Runtime problems? If so, then tell us what they are.
3) Your
user constructor doesn't make much sense:
1 2 3 4 5 6 7
|
user::user(string n, string s, int tc, personTypes pt, card_Types ct, card c1, card c2)
:person(n, s, tc, pt, ct, c1, c2){
c1 = card::card(ct,0);
c2 = card::card(ct, 0);
card1 = c1;
card2 = c2;
}
|
Why are you trying to assign values to
c1 and
c2? You're passing those arguments into
user::user(), and then trying to immediately overwrite them with new objects in lines 3 - 4.
Then, having overwritten your values of
c1 and
c2 with new values, the only thing you do with them is to assign them to the data members
card1 and
card2, which makes the whole existence of
c1 and
c2 pointless.
I suspect what you really intended to do is to pass
c1 and
c2 into the
user constructor, and set the data members equal to those objects. In that case, you want to get rid of lines 3 - 4 entirely, and simply assign the values of
c1 and
c2 to
card1 and
card2.
However...
4) Assigning values to data members in a constructor is inefficient. In your example, first,
card1 and
card2 are default-constructed, and then assignment occurs. It's much more efficient to use an initialiser list, so those objects are simply constructed with the desired values:
1 2 3 4 5 6
|
user::user(string n, string s, int tc, personTypes pt, card_Types ct, card c1, card c2)
: person(n, s, tc, pt, ct, c1, c2)
, card1(c1)
, card2(c2)
{
}
|
5) I can see you're passing
c1 and
c2 into the constructor for
person. That makes me suspicious. You haven't shown us the definition of
person. Does
person need those values for anything? You're storing those objects in the
user subclass; why do that if the base class is already storing them?