Program Help; 2 fatal error regarding virtual/polyhmorphism code

This is an assignment that require students write in virtual function with at least one pure virtual function. I did a portion of the code, but when I compile, there are 2 Linked error, which I cannot figure out where is wrong with my program. Please take a look and help me out.

#include<iostream>
#include<string>
#include<iomanip>
using namespace std;

class item
{
public:
item(const char*, const char*);
~item();
virtual float clacShippingCost() const;
virtual void print() const;

private:
char *firstName;
char *lastName;
};
item::item(const char *first, const char *last)//directly copy from poly4
{
firstName = new char[strlen(first) + 1];
strcpy(firstName, first);
lastName = new char[strlen(last) + 1];
strcpy(lastName, last);
}
void item::print() const
{
cout<<firstName<< ' '<<lastName;
}
item::~item()
{
delete[]firstName;
delete[]lastName;
}

class tShirt: public item //tShirt class inhereit from item class
{
public:
tShirt(const char*, const char*, const char*,const char*,const char*, int,const char*, int, bool, bool);
virtual float calcShippingCost() const;
virtual void print() const;

private:
const char *street;
const char *city;
const char *state;
int zipcode;
const char *expdate;
int numberOfTshirt;
bool overnight;
bool insurance;
};
float tShirt::calcShippingCost() const
{
float temp;
if(insurance == true)
{
if(overnight == true)//if the customer wants BOTH insurance and overnight; then it will be 1.02(2.75 * # of tshirt + $10 overnight shipping )
{
temp = 2.75 * numberOfTshirt + 10;
return 1.02 * temp;
}
else //if the customer only want the insurance but not the overnight
return 1.02 * 2.75 * numberOfTshirt;
}
else
{
if(overnight ==true)//customer only want overnight but no insurance
return 2.75 * numberOfTshirt +10;
else //regular shipping; NO overnight, NO insurance
return 2.75 * numberOfTshirt;

}

}
void tShirt::print() const
{
cout<<"Customer: ";
item::print();
cout<< street<<endl;
cout<<city<<", "<<state<<" "<<zipcode<<endl;
cout<<expdate<<endl;
}

void main()
{
tShirt t("Joe", "Blow", "123 Main", "New York", "NY", 11111, "1/1/2011", 5, true, true);
t.calcShippingCost();
}

I'm seeing these:
1>main.obj : error LNK2001: unresolved external symbol "public: virtual float __thiscall item::clacShippingCost(void)const " (?clacShippingCost@item@@UBEMXZ)

1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall tShirt::tShirt(char const *,char const *,char const *,char const *,char const *,int,char const *,int,bool,bool)" (??0tShirt@@QAE@PBD0000H0H_N1@Z) referenced in function _main

spelling error - clacShippingCost

don't forget to define the object - item t;

which changes the error to:
1>c:\main.cpp(83) : error C2512: 'item' : no appropriate default constructor available
Last edited on
I fixed the spelling error, but it still shows up those two errors
[code] "Please use code tags" [/code]
You never defined those methods
1
2
virtual float calcShippingCost() const;
tShirt(char const *,char const *,char const *,char const *,char const *,int,char const *,int,bool,bool)


Also, use strings instead of char * http://www.cplusplus.com/reference/string/string/
Last edited on
Topic archived. No new replies allowed.