#include <iostream> #include <string> #include <stdlib.h> #include \"card.h\" us
ID: 3768880 • Letter: #
Question
#include <iostream>
#include <string>
#include <stdlib.h>
#include "card.h"
using namespace std;
card::card()
{
cardID = 0;
bookID = 0;
card = (char n[], char p[], int c);
}
card::card(char n[], char p[], int c)
{
cardID = c;
strcpy(Name, n);
strcpy(Phone, p);
bookID = 0;
}
int card::getCardID()
{
return cardID;
}
bool card::hasBook()
{
if (bookID == 0)
return false;
else
return true;
}
void card::checkOut(int b)
{
bookID = b;
}
void card::checkIn()
{
cardID = 0;
}
void card::print()
{
cout << cardID << " "
<< Name << " "
<< Phone << " "
<< bookID << endl;
}
void card::printName()
{
cout << Name;
}
whats wrong with this? im getting errors saying no member function was called in class card
my card.h has this:
class card
{
private:
char name[30];
char phone[15];
int cardID;
int bookID;
public:
card();
card(char n[], char p[], int c[]);
void setCardID(int c);
void setName(char n[]);
void setPhone(char p[]);
void setBookID(int b);
int getBookID();
int getCardID();
void printcard();
};
what could the error be? ive matched everything up but still getting errors?
Explanation / Answer
you must define your class first and the the functions in it.
class card
{
private:
char name[30];
char phone[15];
int cardID;
int bookID;
public:
card();
card(char n[], char p[], int c[]);
void setCardID(int c);
void setName(char n[]);
void setPhone(char p[]);
void setBookID(int b);
int getBookID();
int getCardID();
void printcard();
};
card::card()
{
cardID = 0;
bookID = 0;
card = (char n[], char p[], int c);
}
card::card(char n[], char p[], int c)
{
cardID = c;
strcpy(Name, n);
strcpy(Phone, p);
bookID = 0;
}
int card::getCardID()
{
return cardID;
}
bool card::hasBook()
{
if (bookID == 0)
return false;
else
return true;
}
void card::checkOut(int b)
{
bookID = b;
}
void card::checkIn()
{
cardID = 0;
}
void card::print()
{
cout << cardID << " "
<< Name << " "
<< Phone << " "
<< bookID << endl;
}
void card::printName()
{
cout << Name;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.