My question is simple: What's the point in defining elements in the function template declaration versus doing it in the body?
As an example, a snippet from my textbook.
template<class ItemType>
class ArrayBag : public BagInterface<ItemType>
{
private:
static const int DEFAULT_CAPACITY = 6;
ItemType items[DEFAULT_CAPACITY];
int itemCount;
int maxItems;
public:
ArrayBag();
}
template<class ItemType>
ArrayBag<ItemType>::ArrayBag(): itemCount(0), maxItems(DEFAULT_CAPACITY)
{
}
and what's the difference between doing something like
template<class ItemType>
ArrayBag<ItemType>::ArrayBag()
{
itemCount = 0;
maxItems = DEFAULT_CAPACITY;
}
Is it just ease of access or is it more effective in processing power?
Thanks