Okay, so I've gotten my second project in C++ and this seems pretty extream for a second project to me, but I'm determined to get this working. so my teacher suplied two header files (set.h and bingoball.h) our job is to take those files and program a bingoball.cpp and a set.cpp, he will than make a generic main.cpp to test our codes. I'm having a lot of trouble with calling functions from other files, I've just started writing the first function of creating a new random bingo ball from 1-75 that than adds the appropriate number. and I just wanted to test that it was working before moving on to more functions, but my lack of knowledge on the syntex of multiple files is holding me back. if someone could help me figure out how to call functions to an object I created and clairify what I'm doing horibly horibly wrong that would be awesome. Currently I get a LNK2019 error when I try to compile for "unresolved external symbol".....
I'm sorry, but this is just gonna be bad.
set.h provided by teacher that is not allowed to be changed:
#ifndef SET_H
#define SET_H
#include <string>
using namespace std;
template <class type>
class set
{
public:
explicit set();
//constructs an empty set of objects
type remove();
//removes a random element of the set and returns it
//else returns null
type remove(type t);
//removes a specific element of the set and returns it if it exists
//returns null if it doesn't
bool add(type t);
//adds a specific element to the set if not already there
//returns true if it is successful and false if not
string toString();
//prints out the entirety of the set
};
#endif /* SET_H */
bingoball.h file provided by the teacher and not allowed to be changed:
#ifndef BINGOBALL_H
#define BINGOBALL_H
#include <string>
#include <stdexcept>
using namespace std;
class bingoBall
{
private:
int num;
char letter;
public:
explicit bingoBall();
//constructs a random bingoBall which a member of the universe of bingoBalls
explicit bingoBall(int) throw(invalid_argument);
//constructs a bingoBall of number int (1-75) if outside of range, throw()
//assigns char as follows
//int = 1-15 = B
//int = 16-30 = I
//int = 31-45 = N
//int = 46-60 = G
//int = 61-75 = O
explicit bingoBall(int, char) throw(invalid_argument);
//constructs a bingoBall of number int and letter char
//must be validated if char or int is outside of range, throw()
bool isEqual(bingoBall b);
//compares self to b, return true if equal, otherwise return false
string toString();
//returns a string of the balls value e.g.: "B7"
};
#endif /* BINGOBALL_H */
The hell that is what I've tried to code for BingoBall.cpp:
#include "BingoBall.h"
#include "Set.h"
#include <string>
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
void BingoBall();
void isEqual();
string toString();
int ballValue = 0;
string ballName = "";
string tempChar = "";
int tempValue = 0;
string tempBallName = "";
bingoBall::bingoBall()
{
}
static void bingoBall()
{
ballValue = rand() % 75 + 1;
if (ballValue < 16)
{
ballName = "B" +ballValue;
}
else if (ballValue < 31)
{
ballName = "I" +ballValue;
}
else if (ballValue < 46)
{
ballName = "N" +ballValue;
}
else if (ballValue < 61)
{
ballName = "G" +ballValue;
}
else if (ballValue < 76)
{
ballName = "O" +ballValue;
}
}
void isEqual()
{
}
static string toString()
{
return ballName;
}
I don't see any reason this should not work so I can only assume I am encountering more than one syntex problem...
my set.cpp is nothing but defined functions with nothing in them so far.
and these are the two diffrent methods that I've tried to put in a main file to call on bingoBall();
bingoBall bingoBall_obj;
bingoBall bingoBall();
cout << bingoBall_obj.bingoBall();
bingoBall* bingoBall_obj = new bingoBall();
bingoBall_obj -> bingoBall();
cout << bingoBall_obj -> toString();
any help at all would be great, I've only been in this class for 4 weeks, and this is only our second project...this class does not teach us c++, but it requires us to know it, so I'm sucking I know, but at least I'm trying.