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!!! :'(

I would really appreciate any help any one can give me, this is supposed to be due in 3 hours! AHHH!

It's impossible to read without code tags and formatting:

[code]

// paste code here

[/code]

You have some stray brackets in there, which I assume is an attempt to post with code tags, but I'm not sure. If they are in the code itself, delete them. Start by commenting everything out in main except for return 0; See if it compiles then. Start uncommenting a line at a time in main till you get an error. This error here:

undefined reference to `screen::screen()'

suggests that you have a definite problem in your Screen class, which you said was OK. In particular, make sure it can compile these two lines in the beginning of main.

screen S;
Brush B;

This error suggests that you won't get past the first line above.

undefined reference to `screen::screen()'

You can temporarily make everything public too and see if that helps, but I doubt that's the problem, so save it for later. Uncomment main one line at a time from the top till you get your first error. Ignore the other errors, fix the first, then try again. Also, repost with code tags please.

Its already 3 hours past .. but here are a couple of things I see

Your screen.h file has

#ifndef SCREEN_H
#define SCREEN_H

#include "Screen.cc"

And your screen.c file has

#ifndef SCREEN_H
#define SCREEN_H

#include "Screen.h"

.. not a good idea imo. I would suggest removing the "#include Screen.cc" from your header file and removing the #ifdefs from your screen.cc file.

If you have the same stuff in Brush.[ch] fix that accordingly and then try to re-compile.

Thank you for your help! OK I took your advise and changed my .cc files and I get the following errors:
g++ -c -o assign3.o assign3.cc
assign3.cc: In function ‘int main()’:
assign3.cc:21: error: ‘brush’ was not declared in this scope
assign3.cc:21: error: expected `;' before ‘B’
assign3.cc:51: error: ‘B’ was not declared in this scope
assign3.cc:57: error: ‘B’ was not declared in this scope
assign3.cc:63: error: ‘B’ was not declared in this scope
assign3.cc:66: error: ‘B’ was not declared in this scope
assign3.cc:68: error: ‘B’ was not declared in this scope
assign3.cc:70: error: ‘B’ was not declared in this scope
assign3.cc:72: error: ‘B’ was not declared in this scope
assign3.cc:74: error: ‘B’ was not declared in this scope
assign3.cc:76: error: ‘B’ was not declared in this scope
assign3.cc:78: error: ‘B’ was not declared in this scope
assign3.cc:80: error: ‘B’ was not declared in this scope
make: *** [assign3.o] Error 1

Originally when I wrote this program I wrote it in one big file and it complied correctly so that is how I know the functions all work correctly and it has something to do with splitting them up and calling them. Would it have anything to do with my #ifndef and #endif statements?
I'm going to turn it in late, being a perfectionist I'd rather have it work than turn in a bad program!!! THANK YOU AGAIN!!!

Also were writing our own makefile ... could this be the problem? Here is my make file

CC = g++
CCFLAGS = -Wall

assign3:  assign3.o Screen.o Brush.o
        $(CC) $(CCFLAGS) -o assign3.o Screen.o Brush.o

assign3.: assign3.cc Screen.cc Brush.cc
        $(CC) $(CCFLAGS) -c assign3.o

Screen.o:  Screen.cc Screen.h
        $(CC) $(CCFLAGS) -c screen.o

Brush.o: Brush.cc Brush.h
        $(CC) $(CCFLAGS) -c Brush.o

clean:
        -rm *.o
        -rm assign3.

also thank you for showing me how to used the code quoting!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.