I have a class screen and a class Brush both have header files and source files. The driver file shown first was provided to us so nothing should be wrong with it but I wanted to show you how it worked.
#include <iostream>
#include <string>
#include "Screen.h"
#include "Brush.h"
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main()
{
// function prototype
void print_menu();
screen S;
Brush B;
bool IMFlag = true;
bool QuitFlag = false;
string Command;
char NewColor;
int NewWidth, NewHeight;
int NewRow, NewColumn;
char NewWord[81];
S.clear();
print_menu();
// This is the large loop controlling the activities.
while (!QuitFlag)
{
cin >> Command;
if (Command == "Q")
QuitFlag = true;
else if (Command == "CS")
S.clear();
else if (Command == "DISP")
S.print();
else if (Command == "NI")
IMFlag = false;
else if (Command == "IN")
IMFlag = true;
else if (Command == "BP")
{
if (IMFlag) cout << "At what row and column should we draw?" << endl;
cin >> NewRow >> NewColumn;
B.draw_position(S, NewRow, NewColumn);
}
else if (Command == "BC")
{
if (IMFlag) cout << "What is the new color?" << endl;
cin >> NewColor;
B.set_color(NewColor);
}
else if (Command == "BS")
{
if (IMFlag) cout << "What are the new width and height?" << endl;
cin >> NewWidth >> NewHeight;
B.set_size(NewWidth, NewHeight);
}
else if (Command == "BU")
B.draw_up(S);
else if (Command == "BD")
B.draw_down(S);
else if (Command == "BL")
B.draw_left(S);
else if (Command == "BR")
B.draw_right(S);
else if (Command == "BUL")
B.draw_up_left(S);
else if (Command == "BUR")
B.draw_up_right(S);
else if (Command == "BDL")
B.draw_down_left(S);
else if (Command == "BDR")
B.draw_down_right(S);
else if (Command == "WP")
{
if (IMFlag) cout << "At what row and column should we write?" << endl;
cin >> NewRow >> NewColumn;
S.set(NewRow, NewColumn);
}
else if (Command == "WD")
{
if (IMFlag) cout << "What word should we write?" << endl;
cin >> NewWord;
S.write(NewWord);
}
else
{
cout << "Command " << Command << " not recognized." << endl;
print_menu();
}
if (IMFlag) S.print();
}
return 0;
}
]
[B][U]Screen class header:[/U][/B]
[#ifndef SCREEN_H
#define SCREEN_H
#include "Screen.cc"
using namespace std;
class screen
{
#define ROWS 23 //or const static int ROWSIZE = 23
#define COLUMNS 75 //or const static int COLUMNSIZE = 75
public:
int Row_Position;
int Column_Position;
char Screen_Array [ROWS][COLUMNS];
screen ();
void print();
void clear();
void set(int, int);
void plot(int, int, char);
void write(char[]);
};
#endif
]
[B][U]Screen Source code:[/U][/B]
[#ifndef SCREEN_H
#define SCREEN_H
#include "Screen.h"
//code classes defined here... those are all fine
#endif]
[B][U]Brush Header code:[/U][/B]
[#ifndef BRUSH_H
#define BRUSH_H
#include "Brush.cc"
class Brush
{
friend class screen; //including the screen class
public:
int Brush_Row; //holds the Brush's Row position
int Brush_Column; //holds the Brush's Column position
int Brush_Height; //holds the Brush's Height
int Brush_Width; //holds the Brush's Width
char color; //holds the Brush's color character
Brush (); //The Constructer for the Brush class
private:
void draw(screen, int, int);
public:
void set_color(char);
void set_size(int, int);
void draw_position(screen, int, int);
void draw_left(screen);
void draw_right(screen);
void draw_up(screen);
void draw_down(screen);
void draw_up_left(screen);
void draw_up_right(screen);
void draw_down_left(screen);
void draw_down_right(screen);
};
#endif]
[B][U]Brush source code:[/U][/B]
[#ifndef BRUSH_H
#define BRUSH_H
#include "Brush.h"
//code for class methods here which all are fine
#endif]
Error Messages:
g++ -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" assign3.cc -o assign3
/tmp/ccYfz12E.o: In function `main':
assign3.cc:(.text+0x26e): undefined reference to `screen::screen()'
assign3.cc:(.text+0x277): undefined reference to `Brush::Brush()'
assign3.cc:(.text+0x294): undefined reference to `screen::clear()'
assign3.cc:(.text+0x2e5): undefined reference to `screen::clear()'
assign3.cc:(.text+0x308): undefined reference to `screen::print()'
assign3.cc:(.text+0x3bd): undefined reference to `Brush::draw_position(screen, int, int)'
assign3.cc:(.text+0x414): undefined reference to `Brush::set_color(char)'
assign3.cc:(.text+0x476): undefined reference to `Brush::set_size(int, int)'
assign3.cc:(.text+0x4ad): undefined reference to `Brush::draw_up(screen)'
assign3.cc:(.text+0x4e4): undefined reference to `Brush::draw_down(screen)'
assign3.cc:(.text+0x51b): undefined reference to `Brush::draw_left(screen)'
assign3.cc:(.text+0x552): undefined reference to `Brush::draw_right(screen)'
assign3.cc:(.text+0x589): undefined reference to `Brush::draw_up_left(screen)'
assign3.cc:(.text+0x5c0): undefined reference to `Brush::draw_up_right(screen)'
assign3.cc:(.text+0x5f7): undefined reference to `Brush::draw_down_left(screen)'
assign3.cc:(.text+0x62e): undefined reference to `Brush::draw_down_right(screen)'
assign3.cc:(.text+0x693): undefined reference to `screen::set(int, int)'
assign3.cc:(.text+0x6f0): undefined reference to `screen::write(char*)'
assign3.cc:(.text+0x73e): undefined reference to `screen::print()'
collect2: ld returned 1 exit status
make: *** [assign3] Error 1
PLEASE HELP!!! :'(