GSXdan
09-22-2003, 08:53 PM
so we have started classes in my C++ class, and they seem pretty easy, i have the concept, but i keep getting this error message and i cant figure it out. Im about 99% sure it has to do w/ me sending a char string though.
class:
class Package {
public:
Package(int=0, int=0, int=0, int=0, int=0);
void setDim(int, int, int);
void setWeight(int, int);
void setDestination(char[20]);
int getDirth();
int getWeight(int);
char getCity();
private:
int width;
int height;
int length;
int Wpounds;
int Wounces;
char City[];
};
function:
void Package:: setDestination(char dest[20]) {
cout << "hello" << endl;
//need to copy what comes in to the City object
}
main/call:
Package toBeShipped[100];
ifstream inf;
int l, w, h, p, o;
int numPacks, x;
char dest[20];
numPacks=0;
inf.open("lib/packages.dat");
while(!inf.eof()) {
inf >> w >> l >> h; // input length, width, and height
// call to setDim function to set dimenstions
toBeShipped[x].setDim(l, w, h);
inf >> p >> o; // input pounds and ounces
toBeShipped[x].setWeight(p, o); // call to setWeight to set weight
inf >> dest; // input destination
// call to set the destination
toBeShipped[x].setDestination(dest[20]);
numPacks++;
x++;
}
}
any help would be appreciated as always
thanks ^dan
class:
class Package {
public:
Package(int=0, int=0, int=0, int=0, int=0);
void setDim(int, int, int);
void setWeight(int, int);
void setDestination(char[20]);
int getDirth();
int getWeight(int);
char getCity();
private:
int width;
int height;
int length;
int Wpounds;
int Wounces;
char City[];
};
function:
void Package:: setDestination(char dest[20]) {
cout << "hello" << endl;
//need to copy what comes in to the City object
}
main/call:
Package toBeShipped[100];
ifstream inf;
int l, w, h, p, o;
int numPacks, x;
char dest[20];
numPacks=0;
inf.open("lib/packages.dat");
while(!inf.eof()) {
inf >> w >> l >> h; // input length, width, and height
// call to setDim function to set dimenstions
toBeShipped[x].setDim(l, w, h);
inf >> p >> o; // input pounds and ounces
toBeShipped[x].setWeight(p, o); // call to setWeight to set weight
inf >> dest; // input destination
// call to set the destination
toBeShipped[x].setDestination(dest[20]);
numPacks++;
x++;
}
}
any help would be appreciated as always
thanks ^dan