every time i try to use the function from the card.cpp file in the hand.cpp file it will give me this error undefined reference to `newCard()' and ive tried declaring it in the hand.h file and in the hand.cpp but nothing will work ive also tried to put both the card and hand constructors in the same file but that also did not work ive tried to declare in the private variable which was the closest ive gotten it to run everything else works except this one part
#include <iostream>
//#include "card.cpp"
//#include "hand.cpp"
//#include "hand.h"
using namespace std;
enum Color {wild, red, green, blue, yellow};
enum type {add4, add2, rotate, skip, numCard};
class card{
private:
public:
card();
int number;
Color COLOR;
type TYPE;
string cardvalue;
string send();
string str;
void newCard();
void changeColor();
friend class hand;
//bool operator==(card const & other) const;
card(int num, Color col, type ty);
~card();
};
#include "card.h"
//#include "hand.cpp"
//#include "hand.h"
#include <stdlib.h>
using namespace std;
string cardvalue;
card::card(int num, Color col,type ty)
{
number = num;
TYPE = ty;
COLOR = col;
}
void card::newCard(){
int num1 = rand()% 4;
int wildc = rand()% 1;
int type1 = rand()% 7;
switch(num1){
case 0:
COLOR = wild;
break;
case 1:
COLOR = red;
case 2:
COLOR = green;
case 3:
COLOR = blue;
case 4:
COLOR = yellow;
default:
break;
}
if(COLOR == wild){
switch(wildc){
case 0:
TYPE = add4;
break;
case 1:
break;
default:
break;
}
}
if(COLOR != wild){
switch(type1){
case 0:
TYPE = numCard;
case 1:
TYPE = numCard;
case 2:
TYPE = numCard;
case 4:
TYPE = numCard;
case 5:
TYPE = add2;
case 6:
TYPE = rotate;
case 7:
TYPE = skip;
default:
break;
}
}
if(TYPE == numCard){
number = rand()+1 % 9;
str = to_string(number);
}
if(COLOR == wild){
cardvalue = "W";
if(TYPE == add4){
cardvalue = "W+4";
}
}else if(COLOR == red){
if(TYPE == numCard){
cardvalue = "R" + str;
}else if(TYPE == add2){
cardvalue = "R+2";
}else if(TYPE == rotate){
cardvalue = "RRT";
}else if(TYPE == skip){
cardvalue = "RS";
}
}else if(COLOR == green){
if(TYPE == numCard){
cardvalue = "G" + str;
}else if(TYPE == add2){
cardvalue = "G+2";
}else if(TYPE == rotate){
cardvalue = "GRT";
}else if(TYPE == skip){
cardvalue = "GS";
}
}else if(COLOR == blue){
if(TYPE == numCard){
cardvalue = "B" + str;
}else if(TYPE == add2){
cardvalue = "B+2";
}else if(TYPE == rotate){
cardvalue = "BRT";
}else if(TYPE == skip){
cardvalue = "BS";
}
}else if(COLOR == yellow){
if(TYPE == numCard){
cardvalue = "Y" + str;
}else if(TYPE == add2){
cardvalue = "Y+2";
}else if(TYPE == rotate){
cardvalue = "YRT";
}else if(TYPE == skip){
cardvalue = "YS";
}
}
}
string send(){
//cout << "works" << endl;
return cardvalue;
}
void card::changeColor(){
}
//bool card::operator==(card const & other) const{
//}
card::~card(){
}
#include <iostream>
#include "hand.h"
//#include "card.cpp"
//#include "card.h"
//#include "hand.cpp"
using namespace std;
int main() {
hand p1;
//p1.printHand();
p1.printHand();
}
#include <iostream>
//#include "hand.cpp"
//#include "card.cpp
#include "card.h"
using namespace std;
class hand{
private:
public:
string mainhand[15];
hand();
void sortHand();
void printHand();
//card::card();
//card* newCard();
};
#include "hand.h"
//#include "card.h"
#include <iostream>
#include <stdlib.h>
using namespace std;
card newCard();
hand::hand() {
for(int i = 0 ; i < 7; i++){
newCard();
cout << "bru" << endl;
}
for(int i = 0; i < 7; i++){
cout << "bruh" << endl;
}
}
void hand::sortHand() {
}
void hand::printHand() {
for (int i = 0; i < 15; i++) {
if (mainhand[i].empty()) {
mainhand[i] = "[]";
}
cout << mainhand[i];
}
}