I'm getting this error from this code. I never seen this before.

#include <cstdlib>
#include <string>
#include <iostream>
#include "../incl/rect.h"
#include "../incl/position.h"

using namespace std;

// function prototypes
void displayRectangleAttributes( const RectangleShape &r );
void displayRectangleAttributes( const RectangleShape &s );
string convert( const color &c );


//  
int main()
{
    RectangleShape R( 4.0, 4.0, Blue, 2.0, 3.0 );
    displayRectangleAttributes( R );
    RectangleShape S( 6.0, 6.0, Red, 3.0, 2.0 );
    displayRectangleAttributes( S );
    
    
    system( "PAUSE" );
    return 0;
}


//  DisplayRectangleAttributes(): give a rectangle's vital characeristics
void displayRectangleAttributes( const RectangleShape &r )
void displayRectangleAttributes( const RectangleShape &s )

    // get position

    float rPositionX;
    float rPositionY;
    float sPositionX;
    float sPositionY;

    r.getPosition( rPositionX, rPositionY );
    s.getPosition( sPositionX, sPositionY );

    // get color

    color c;

    c = r.getColor();
    s = s.getColor();   // enum color version of color

    string rColor = convert(c);
       string sColor = convert(c);  // get string version of color


    // get size

    float rLength;
    float rWidth;
    float sLength;
    float sWidth;

    r.getSize(rLength, rWidth);
    s.getSize(sLength, sWidth);

    // display attributes

    cout << "Your " <<  rColor << " rectangle is centered at ("
     << rPositionX << "," << rPositionY << ")  with length " << rLength
     << " and width " << rWidth << endl;
     
     cout << "Your " <<  sColor << " rectangle is centered at ("
     << sPositionX << "," << sPositionY << ")  with length " << sLength
     << " and width " << sWidth << endl;
}

// Convert(): return enum-type color as a string

string convert(const color &c) {

    string s;

    switch (c) {
        case White:
            s = "white";   break;
        case Red:
            s = "red";     break;
        case Green:
            s = "green";   break;
        case Blue:
            s = "blue";    break;
        case Yellow:
            s = "yellow";  break;
        case Cyan:
            s = "cyan";    break;
        case Magenta:
            s = "magenta"; break;
        default:
            cerr << "Unexpected color request: ";
            exit(1);
    }

    return s;
}

This is a pice of a bigger code, my profesor always wants us to create programs in multiple files . I have problems visializing the programs in mulitple files do you guys also work in multiple files?

Recommended Answers

All 3 Replies

>>I'm getting this error from this code
what line number contains the error ?

>> do you guys also work in multiple files?

Yes, my projects at work consist of several hundred files where the implementation code and header file of each c++ class are contained in their own files. This makes maintenance a lot easier than having all million lines of code in one file.

Probably just a typo, but there's no opening curly brace "{" for your function definition:

void displayRectangleAttributes(const RectangleShape &s)

And yes, I find it much easier to work with multiple files than trying to cram it all in one file...

why are lines 30 and 31 identical? you should delete one of them.

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.