fork download
  1. #ifndef __ch1Ex4__card__
  2. #define __ch1Ex4__card__
  3.  
  4. #include <iostream>
  5.  
  6.  
  7. class card
  8. {
  9. public:
  10. card();
  11. ~card();
  12. int getcard();
  13. bool setcard(int card);
  14. bool setsuit(char suit);
  15. char getsuit();
  16.  
  17. private:
  18.  
  19. int card_value;
  20. char suit_type;
  21.  
  22. };
  23.  
  24. #endif /* defined(__ch1Ex4__card__) */
  25.  
  26.  
  27.  
  28.  
  29. #include <iostream>
  30.  
  31. using namespace std;
  32.  
  33. //#include "card.h"
  34.  
  35.  
  36. int main(int argc, const char * argv[])
  37. {
  38. // just creating a class instance for testing.
  39. // Not sure why it is failing.
  40. card test;
  41.  
  42. for (int i = 0; i < 4; i++) {
  43. for (int k = 0; k < 13; k++)
  44. {
  45. switch (i+1) {
  46. case 1: cout << "c";
  47. break;
  48. case 2: cout << "d";
  49. break;
  50. case 3: cout << "h";
  51. break;
  52. case 4: cout << "s";
  53. break;
  54.  
  55. default:
  56. break;
  57. }
  58. cout << " ";
  59. switch (k+1) {
  60. case 1: cout << "A" << endl;
  61. break;
  62. case 11: cout << "J" << endl;
  63. break;
  64. case 12: cout << "K" << endl;
  65. break;
  66. case 13: cout << "Q" << endl;
  67. break;
  68. default:
  69. cout << k+1<< endl;
  70. break;
  71. }
  72. }
  73.  
  74. }
  75.  
  76.  
  77. return 0;
  78. }
  79.  
  80.  
  81.  
  82.  
  83. //#include "card.h"
  84.  
  85. card::card()
  86. {
  87. card_value = 0;
  88. suit_type = NULL;
  89.  
  90. }
  91.  
  92. int card::getcard()
  93. {
  94. return card_value;
  95. }
  96. bool card::setcard(int card)
  97. {
  98. card_value = card;
  99. return true;
  100. }
  101. bool card::setsuit(char suit)
  102. {
  103.  
  104. suit_type = suit;
  105.  
  106. return true;
  107. }
  108. char card::getsuit()
  109. {
  110.  
  111. return suit_type;
  112. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In constructor ‘card::card()’:
prog.cpp:88:15: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
     suit_type = NULL;
               ^
/home/1eiUyw/ccAlmpYy.o: In function `main':
prog.cpp:(.text.startup+0x106): undefined reference to `card::~card()'
prog.cpp:(.text.startup+0x327): undefined reference to `card::~card()'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty