Microsoft Interview Question
Software Engineer / Developerscards hearts = new hearts("Red hearts");
cards diamonds = new diamonds ("Red diamonds");
won't compile...
To make it better...create four child classes from the card and name them as heart,Diamond,Spade etc...
and then create these classes... In the constructor we are not required to provide the color because each subclass will know its own color
well, we can have
- jack.watermelon April 20, 2010class cards
{
private:
int cardsNumber[12];
string cardsColor;
public:
cards(string _cardsColor)
{
cardsColor = _cardsColor;
}
}
void main()
{
cards hearts = new hearts("Red hearts");
cards diamonds = new diamonds ("Red diamonds");
// and so on, we can give ID for different colors and we can also incialize the numbers