Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   HELP! getting unresolved externals error message (http://www.go4expert.com/forums/help-getting-unresolved-externals-error-t5714/)

Marshall 6Aug2007 20:11

HELP! getting unresolved externals error message
 
I'm working on a lab for my C++ class and for some reason i keep getting an 'unresolved externals' error message.

This is a simple program that displays a menu of choices and then displays shapes through function calls. Any help would be appreciated!!!!
Code:

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;


void drawRectangle();
void drawSquare();
void drawRightTriangle();
void drawETriangle();
void drawDiamond();

void main()
{        //start main function

        char choice=0;
        int done=0;
       
        //display menu choices
        //do
        //{
       
        cout<<"Welcome to the shape demonstration program.\n";
        cout<<"Choose one of the menu options below to see a sample of the shape.\n";
        cout<<endl<<endl;
        cout<<setw(5)<<"1.  "<<"Rectangle\n\n";
        cout<<setw(5)<<"2.  "<<"Square\n\n";
        cout<<setw(5)<<"3.  "<<"Right Triangle\n\n";
        cout<<setw(5)<<"4.  "<<"Equilateral Triangle\n\n";
        cout<<setw(5)<<"5.  "<<"Exit the program\n";
        cout<<endl;
       
       
        cin>>choice;
       
       
        switch (choice)                                        //switch is like nested if statements
               
               
        {                                                                //start switch
               
               
        case '1':
                drawRectangle();
                break;
               
        case '2':
                drawSquare();
               
                break;
               
        case '3':
                drawRightTriangle();
               
                break;
               
        case '4':
                drawETriangle();
               
                break;
               
        case '5':
                done=1;
                break;
               
               
        }                                                        //end switch
       
       
       
        if (!done)
        {                                                        //start compound statement if
                system("PAUSE");
                system("CLS");
               
        }                                                        //end of compound statement
       
        return;
       
}                                                        //end of main



void drawRectangle(int height, int width)                                //this function def draws the rectangle

{       
        //note the opening bracket
        //int height, width;
        char symbol;
        int counter;
       
        cout<<"You have chosen the rectangle.  Please enter the desired height and width \n";
        cout<<"of the rectangle separated by a space."<<endl;
       
        cin>>height>>width;
       
        cout<<"You may enter a character of your choice to build this shape.";
        cin>>symbol;
       
       
        for (counter=0;
        counter < height;
        counter++)
               
        {                                                                //note the for loops opening bracket
               
                for
                        (int row=0;
                row < width;
                row++)
                        cout<<'*';
                cout<<endl;
        }                                                                        //note the for loops closing bracket
       
}                                                                        //note the functions closing bracket




void drawSquare()                                //this function def draws the square


{               
        int sqheight, sqwidth, counter, row;
       
       
        cout<<"You have chosen the square.  Please enter the height and width of a square \n";
        cout<<"seperated by a space \n";
        cout<<"For ease of viewing please do not exceed a height or width of 20."<<endl;
        cin>>sqheight>>sqwidth;
       
       
        for (counter=0;
        counter < sqheight;
        counter++)
               
        {
               
                for
                        (row=0;
                row < sqwidth;
                row++)
                        cout<<'0';
                cout<<endl;
        }                                                                        //note the for loops closing bracket
       
       
}                                                                        //note the functions closing bracket





void drawRightTriangle ()                        //this function draws the right triangle

{               
        int rtheight,ilc, olr;
       
       
        cout<<"Please enter the height of the right triangle \n";
        cout<<"For ease of viewing we suggest entering a height less than 20 \n";
       
        cin>>rtheight;
       
       
        for (ilc=0;                                //inner loop represents columns. initialize to zero
        ilc < rtheight;
        ilc++)
               
        {
               
                cout<<'z';
                for
                        (olr=0;                        //outer loop represents rows. initialize to zero
                ilc!=0 && olr < ilc;
                olr++)
                        cout<<'z';
                cout<<endl;
        }
       
       
       
}                                                                //note the functions closing bracket




void drawETriangle ()                                //this function draws the equliateral trianle

{                                                                //starting the function
       
        int eheight,ilc,olr;                //declaring variables
       
       
        cout<<"Please enter the height of the equilateral triangle \n";
        cout<<"For ease of viewing we suggest entering a height less than 20 \n";
       
        cin>>eheight;
       
       
        for (ilc=0;                                //inner loop represents columns. initialize to zero
        ilc < eheight;
        ilc++)
               
        {
               
                cout<<setw(eheight-ilc);
                cout<<'z';
                for
                       
                        (olr=0;                        //outer loop represents rows. initialize to zero
                olr < ilc*2+1;
                olr++)
                        cout<<'z';
                cout<<endl;
        }
       
}


DaWei 6Aug2007 21:09

Re: HELP! getting unresolved externals error message
 
Please read the "Before you make a query" thread. You are asking for free help while behaving rudely.

shabbir 6Aug2007 22:13

Re: HELP! getting unresolved externals error message
 
Quote:

Originally Posted by DaWei
Please read the "Before you make a query" thread. You are asking for free help while behaving rudely.

As of now I have done that for you but try to follow what DaWei has said.

DaWei 6Aug2007 23:39

Re: HELP! getting unresolved externals error message
 
You have declared a function, void drawRectangle (), and you have called that function. The only similar function you have defined is void drawRectangle (int, int). The linker is unable to find the one you actually call.

Marshall 6Aug2007 23:50

Re: HELP! getting unresolved externals error message
 
The definition of rude may be kind of harsh??......

My post was brought on by desparation and as a result i didnt properly check the home page

i was unaware of the protocol - this is my first time visiting this forum. However, i now know the rules and will proceed accordingly.

i'm new to c++ and after spending 4 days on this same error i was ready to pound my head against the wall. surely you can remember the days when you first began coding and have just a smidgen of sympathy :confused:

DaWei 7Aug2007 00:37

Re: HELP! getting unresolved externals error message
 
Hmmmm. I answered your technical question, did I not?

My contention is that a new visitor or member, whether to a church or a forum, should look around and try to determine how things are done. I would never fart, during the sermon, on my first visit to a church. I would not be surprised to discover it was considered rude or thoughtless, should I do so.

Marshall 7Aug2007 01:41

Re: HELP! getting unresolved externals error message
 
as mentioned - i now know the rules of the forum.

I would imagine that you have forgiven me just as i would imagine that you dont typically fart in churches (even if it is not your first visit). i would consider it quite rude to boldly pass gas in any public forum.

and yes you did answer my techincal question, thank you

THank you shabir for your assitance as well.


All times are GMT +5.5. The time now is 03:52.