Thread: constructor error message

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    11

    constructor error message

    I was hoping that someone could explain what my error message means.

    error C2533: 'Inventory::Inventory' : constructors not allowed a return type
    rror C2264: 'Inventory::Inventory' : error in function definition or declaration; function not called

    THIS IS MY CODE
    ---------------------
    #include <iostream.h>
    #include <string.h>
    #include <conio.h>

    class Inventory
    {
    private:
    int sku;
    char itemName[20];
    public:
    Inventory(int=0, char[]="");
    void getInventory();
    void showInventory();
    }

    Inventory::Inventory(int s, char n[])
    {
    sku=s;
    strcpy(itemName,n);
    }

    void Inventory::getInventory()
    {
    cout << "Enter product SKU: ";
    cin >> sku;
    cout << "Enter product name: ";
    cin.getline(itemName, 20);
    }

    void Inventory::showInventory()
    {
    cout << "Product SKU: " << sku << "\n"
    << "Product name: " << itemName << endl;
    }

    void main (void)
    {
    Inventory i;
    i.getInventory();
    i.showInventory();
    return;
    }

  2. #2
    Registered User (*)BLUE's Avatar
    Join Date
    Aug 2002
    Posts
    6
    semicolon.....semicolon.......

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    11
    thanks....................STUPID ME!!!!!!

Popular pages Recent additions subscribe to a feed