So I normally wouldn't bother posting about such a simple thing but I can't for the life of me figure out what I'm doing wrong and it's probably something very simple that i'm over looking.
Getting straight to the point, I'm making an object pointer and then using that pointer to call a method of that particular object.
But for some reason whenever I cout the function as follows:
Entry FirstEntry = Entry(J1,H1);
cout << FirstEntry.getItem() << endl;
cout << FirstEntry.getKey() << endl;
Entry *siz = new Entry();
cout << siz->getItem() << endl;
It gives me a blank line being output. Whereas it should be giving me my item value. The Object itself looks like such:
Entry::Entry() {
}
Entry::Entry(KeyType & Key, ItemType & newItem)
{
setKey(Key);
setItem(newItem);
}
Entry::~Entry()
{
}
ItemType Entry::getItem() const
{
return item;
}
KeyType Entry::getKey() const
{
return searchKey;
}
void Entry::setItem(const ItemType & newItem)
{
item = newItem;
}
void Entry::setKey(const KeyType & Key)
{
searchKey = Key;
}
I've been staring at this code for awhile and I can't quite figure out what's causing it to output just a blank line.
Thank you very much for your patience,
Aucun commentaire:
Enregistrer un commentaire