Linker Error Help

Started by
0 comments, last by silothesuper 17 years, 12 months ago
Hello, I was creating a Program like a Shopping Onliine Kinda thing, and I got a Program. The error says "[Linker Error]undifined reference to Womans()". I tried adding "float& totalCost" into the parameters of Womans(), but that didnt work,. I also tried just adding "totalCost", but that didnt really work either. Heres my Code, please Help me findout Whats wrong! NOTE: Im using DevC++.
/*=================================================>
Name: Splix Online Super Store
Date: 4-23-06
Description: A Fake Online Super Store
Programmer Name: Nuclear Rabbit
<=================================================*/
           
#include <iostream>
#include <windows.h>

void Mens();
void Womans();
// void Boys();
// void Girls();              // Havent Created thse yet
// void Toys();
// void Electronics();
// void HomeAppliance();
// void CheckOut();
void StoreMenu();

//Const Prices
const float MENS_PACK1 = 101.50;
const float MENS_PACK2 = 69.99;

const float WOMANS_PACK1 = 115.95;
const float WOMANS_PACK2 = 74.95;

const float BOYS_PACK1 = 75.99;
const float BOYS_PACK2 = 59.95;

const float GIRLS_PACK1 = 79.99;
const float GIRLS_PACK2 = 68.95;

const float TOYS_PACK1 = 29;
const float TOYS_PACK2 = 20;

const float ELEC_PACK1 = 99.99;
const float ELEC_PACK2 = 78.99;

const float HOME_PACK1 = 67.50;
const float HOME_PACK2 = 51.99;

void Mens()
{
     float totalCost;
     int mensItem;
     
     
     system("cls");
     std::cout << ":: 1) Mens Package # 1 :: \n"  //First Package Listings
               << "Pants - $19.99\n"
               << "Shorts - $14.95\n"
               << "Shirts - $9.99\n"
               << "Hoodies - $30\n"
               << "Shoes - $49.99\n\n"
               << "Total: $101.50\n\n"
               << "2)Mans Package # 2\n\n"  // Second Package Listings
               << "Pants - $19.99\n"
               << "Shirts - $14.95\n"
               << "Hoodies - $30\n"
               << "Shorts - $14.95\n\n"
               << "Total: $69.99\n\n"
               << "Which Package Would You Like? Type 0, if None. : ";
     std::cin >> mensItem;
     
     switch (mensItem)
     {
     case 0:
              std::cout << "No Mens Clothes Added To Your Shopping Cart.";
                Sleep(4000);
                system("CLS");
                StoreMenu();
                break;
     case 1:
              std::cout << "\n\nMens Package #1 Added To Your Virtual Shoppingcart.";
                totalCost += MENS_PACK1;
                Sleep(4000);
                system("CLS");
                StoreMenu();  
                break;
     case 2:
              std::cout << "\n\nMens Package #2 Added To Your Virtual ShoppingCart.";
                totalCost += MENS_PACK2;
                Sleep(4000);
                system("CLS");
                StoreMenu();
                break;
     default:
               std::cout << "That is Not one of Our Products.";
                 Sleep(4000);
                 system("CLS");
                 StoreMenu();
                 break;
     }
}

void Womans(float& totalCost)
{
     int womansItem;
     
     system("CLS");
     std::cout << ":: 1) Womans Package # 1 ::\n"
               << "Pants - $30\n"
               << "Shirt - $17.99\n"
               << "Makeup - $9.99\n"
               << "Shoes - $37.95\n"
               << "Jacket - $49.99\n\n"
               << "Total: $ " << WOMANS_PACK1
               << "\n\n:: 2) Womans Package # 2 ::\n"
               << "Pants - $30\n"
               << "Shirt - $17.99\n"
               << "Shoes - $37.95\n\n"
               << "Total: $ " << WOMANS_PACK2
               << "Would Like Any Of These? Type 0, if Not: ";
     std::cin >> womansItem;
     
     switch (womansItem)
     {
            case 0:
                     system("CLS");
                     std::cout << "No Items Added To Your Shoppingcart.";
                       Sleep(4000);
                       StoreMenu();
                       break;
            case 1:
                     system("CLS");
                     std::cout << "Womans Package #1 Added To Your Shoppingcart.";
                     totalCost += WOMANS_PACK1;
                       Sleep(4000);
                       StoreMenu();
                       break;
            case 2:
                     system("CLS");
                     std::cout << "Womans Package #2 Added To Your Shopping Cart.";
                     totalCost += WOMANS_PACK2;
                       Sleep(4000);
                       StoreMenu();
                       break;
            default:
                      system("CLS");
                      std::cout << "Thats Not A Product Number.";
                        Sleep(4000);
                        StoreMenu();
                        break;
     }
}

void StoreMenu()
{
     int selection;
    std::cout << "::::::::::::::::::::::::::::::::::::::::::::::::\n"
              << "::                                            ::\n"
              << "::    Welcome To Splix Online Super Store!    ::\n"
              << "::                                            ::\n"
              << "::::::::::::::::::::::::::::::::::::::::::::::::\n\n"
              << "1) Mens Clothing\n"
              << "2) Womans Clothing\n"
              << "3) Boys Clothing\n"
              << "4) Girls Clothing\n"
              << "5) Toys\n"
              << "6) Electronics\n"
              << "7) Home Appliances\n"
              << "8) Checkout\n\n"
              << "Your Destination : ";
    std::cin >> selection;
    
    switch (selection)
    {
           case 1:
                    system("CLS");
                    Mens();
                    break;
           case 2:
                    system("CLS");
                    Womans();
                    break;
           
           default:
                    std::cout << "Thats Not in Our Store.";
                      Sleep(3000);
                      StoreMenu();
                      break;
    }
}

int main()
{
    StoreMenu();
    return 0;
}



Thanks For Any Help.
Advertisement
Its saying "Undefined Reference to Womans()" because it cant find the actual function called void Womans().

You define the function as void Womans() and then when you write the actual function, you have void Womans(float& totalCost). You must make the definition and the function the same.

This topic is closed to new replies.

Advertisement