ベクトルを作成し、それにバブルソートを使用するクラスを作成しようとしています。バブルと呼ばれる BubbleStorage クラスを作成しようとした場合を除いて、すべて正常にコンパイルされます。
コンパイラは、「バブルの前にテンプレート引数がありません」、「バブルの前に予想されます」というエラーを表示します。
このコードは完成していません。ただし、私はまだバブルソート機能を作成中です。先に進む前に、これを処理したいだけです。
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <vector>
using namespace std;
template<typename T>
class BubbleStorage
{
public:
BubbleStorage();
~BubbleStorage();
vector<T>MyVector;
void add_data(int size)
{
srand (time(NULL));
for (T i = 0; i <= size; i++)
random = rand() % 100;
MyVector.push_back(random);
}
void display_data()
{
cout<<"The Vector Contains the Following Numbers"<<endl;
for (vector<int>::iterator i = MyVector.begin(); i != MyVector.end(); ++i)
cout<<' '<< *i;
}
void max()
{
}
void min()
{
}
};
int main(int argc, char *argv[])
{
srand (time(NULL));
int size = rand() % 50 + 25;
BubbleStorage bubble;
bubble.add_data(size);
bubble.display_data();
}