error message, what does it mean?

This is a discussion on error message, what does it mean? within the C++ Programming forums, part of the General Programming Boards category; I keep getting this error message every time I compile my program. I compile my program like this: CC filename.cc ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    23

    error message, what does it mean?

    I keep getting this error message every time I compile my program. I compile my program like this: CC filename.cc filename.cpp because I'm dealing with classes and I keep getting this error message:
    Id: warning: file rectangle.o: attempted multiple inclusion of fil
    Undefined first referenced
    symbol in file
    main /opt/SUNWspro/SC5.0/lib/crt1.o
    Id: fatal: Symbol referencing errors. No output written to a.out

  2. #2
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    looks like you tried to use something without it being defined. Post some code. Could just be a spelling error.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    23
    I got the same error message with two of my programs. Here's the first program:
    //header file

    #ifndef LAB8_H
    #define LAB8_H

    //creates class
    class RaceCar {
    private:
    int car_num;
    double tank_size;
    int max_speed;
    static int CarCount;
    public:
    void display();
    RaceCar();
    void input(int, double, int);
    static void ShowCarCount();
    };

    #endif


    //member functions definitions

    #include <iostream>

    using std :: cout;
    using std :: endl;
    using std :: cin;

    #include "lab8.h"

    void RaceCar :: display () {

    cout << "Car number: " << car_num << endl;
    cout << "Tank size: " << tank_size << endl;
    cout << "Max speed: " << max_speed << endl;
    }
    int RaceCar :: CarCount = 0;

    RaceCar :: RaceCar () { ++CarCount; }

    void RaceCar :: ShowCarCount () {

    cout << "Car Count: " << CarCount << endl;
    }
    void input (int num, double size, int speed) {

    cin >> num >> size >> speed;

    }


    #include <iostream>

    using std :: cout;
    using std :: cin;
    using std :: endl;

    #include "lab8.h"

    int main ()
    {

    RaceCar r;

    r.input(2, 20, 200);
    r.display();
    r.ShowCarCount();

    return 0;
    }

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    23
    Here's my second program:
    #ifndef RECTANGLE_H
    #define RECTANGLE_H

    class Rectangle {
    private:
    double length;
    double width;
    double length2;
    double width2;
    public:
    Rectangle(double = 0.0, double = 0.0, double = 0.0, double = 0.0);
    double perimeter (double, double);
    double area (double, double);
    void set_rectangle (double, double, double, double);
    double get_length();
    double get_width();
    double square (double, double, double, double);
    };

    #endif

    //member function definitions for Rectangle class

    #include "rectangle.h"

    Rectangle::Rectangle(double l, double w, double ll, double ww) {

    set_rectangle(l, w, ll, ww);

    }
    void Rectangle::set_rectangle (double l, double w, double ll, double ww) {

    length = (l >= 0.0 && l <= 20.0) ? l : 0.0;
    length2 = (ll >= 0.0 && ll <= 20.0) ? ll : 0.0;
    width = (w >= 0.0 && w <= 20.0) ? w : 0.0;
    width2 = (ww >= 0.0 && ww <= 20.0) ? ww : 0.0;

    square(l, w, ll, ww);
    }
    double Rectangle::get_length() { return length; }

    double Rectangle::get_width() { return width; }

    double Rectangle:erimeter (double l, double w) {

    length = l;
    width = w;

    return ((2 * 1) + (2 * w));
    }
    double Rectangle::area (double l, double w) {

    length = l;
    width = w;

    return (l * w);
    }
    double Rectangle::square (double l, double w, double ll, double ww) {

    length = l;
    length2 = ll;
    width = w;
    width2 = ww;

    if (((l != w) && (ll != ww)) && ((l == w) && (ll == ww)))
    return 0;
    else
    return 1;

    }

    //main function

    #include <iostream>

    using std :: cout;
    using std :: endl;

    #include "rectangle.h"
    int main () {

    Rectangle r;

    if((r.square (8.0, 2.4, 8.0, 2.4)) == 0) {
    cout << "Perimeter is: " << r.perimeter (8.0, 2.4) << endl;
    cout << "Area is: " << r.area (8.0, 2.4) << endl;
    }else {
    cout << "It's not a rectangle" << endl;
    }

    return 0;
    }

  5. #5
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    In your first program you forgot to scope the input function in the definition of it.

    should be
    void RaceCar::input( blah blah blah)
    {
    // more code
    }


    I'm working on the second now
    If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?

  6. #6
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    second one compiled just fine for me.
    Sorry.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21