[E1]「C++ では、すべての宣言に型指定子が必要です」、[E2]「宣言されていない識別子が使用されています」、[E3]「クラス名または名前空間が必要です」というエラーがいくつか発生します。
#ifndef MAIN_SAVITCH_SEQUENCE_H
#define MAIN_SAVITCH_SEQUENCE_H
template <class T>
class sequence
{
public:
// TYPEDEFS and MEMBER CONSTANTS
typedef T value_type;
static const int CAPACITY = 30;
// CONSTRUCTOR
sequence( );
// MEMBER FUNCTIONS
void showSequence();
void attach(value_type entry);
value_type current( );
void remove_current( );
int size( );
private:
value_type data[CAPACITY];
int used;
};
template <class T>
[E3] sequence::sequence( )
{
[E2] used = 0;
}
template <class value_type>
[E3] void sequence::attach(value_type entry)
{
data[used++] = entry;
}
sequence::value_type sequence::current( )
//replace sequence::value_type with typename value_type for your template
{
return data[used-1];
}
void sequence::remove_current( )
{
used--;
}
int sequence::size( )
{
return used;
}
void sequence::showSequence()
{
std::string display = "";
for (int i = 0; i<used; i++)
std::cout << data[i] << "\n";
}
#endif