If this is the original class:

class StorageBin
	   {
	      public:
		StorageBin();
		~StorageBin();
		void PutInBin( int Item, int Location);
		int ReturnFromBin (int Location);
		bool FindInBin(int Item);
		void DisplayBin();
	      private:
		int *pBin;
		int NumberInBin;
		int BinSize;
	   };

Would this be the correct conversion to make it a template?

Template <class T>
	class StorageBin
	   {
	      public:
		StorageBin();
		~StorageBin();
		void PutInBin( T Item, T Location);
		T ReturnFromBin (T Location);
		bool FindInBin(T Item);
		void DisplayBin();
	      private:
		int *pBin;
		int NumberInBin;
		int BinSize;
	   };

I ask because it compiles correctly, but as I have learned, that is not always the acid test

Is my question really that dumb that I get nearly 30 views and no replies...lol

Is my question really that dumb that I get nearly 30 views and no replies...lol

You answered your own question.

You answered your own question.

If you are referring to the first question, I know it compiles, but I also know that doesn't necessarily mean it's right, was just looking for a confirmation that it's correct for a template, or no, you're missing stuff.

If you are referring to the second question, that is an odd response coming from you, you're normally very polite and very helpful

If you are referring to the first question, I know it compiles, but I also know that doesn't necessarily mean it's right, was just looking for a confirmation that it's correct for a template, or no, you're missing stuff.

It's correct because you've generalized your list. That's one of the primary functions of templates - to make a general case for all valid objects/types.

Instead of only taking ints, it now takes anything that is a valid T parameter.

There are other reasons for templates, such as meta-programming and (supposedly) allowing a potential "bridge" for inheritance issues but from what I've heard the bridging isn't really a serious performance bump.

If you want an example of template meta-programming, consider the following code--

#include <cstdlib>
#include <iostream>

using namespace std;

class Fibonacci{
     public:
            template<int N>
            inline unsigned __int64 series(){   
                return (this->series<N - 1>() + (this->series<N - 2>()));
            }
};

template<>
inline unsigned __int64 Fibonacci::series<1>(){
    return 1;
};

template<>
inline unsigned __int64 Fibonacci::series<0>(){
    return 0;
};

int main(int argc, char *argv[]){
    const int n = 6;
    Fibonacci fib;
    cout << fib.series<n>() << endl; //prints out the nth result of the Fibonacci series
    cin.get();
    return 0;
}
commented: Alex was, as usual very helpful and very kind in his replies +1

Thank you Alex, as usual, you are the soul of courtesy, my apologies if you took any offense to the second comment.

Thank you Alex, as usual, you are the soul of courtesy, my apologies if you took any offense to the second comment.

No offense taken. My response wasn't fairly directed so the reply is understandable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.