- #1
anonim
- 40
- 2
- Homework Statement
- BAdapter: This class takes a template parameter and behaves like an adaptor class just like the stack or queue class of the STL. The parameter classes can be any STL class with a random access iterator.
- Relevant Equations
- -
in .h file I write like this:
Actually, I did not understand exactly what I was expected to do, but I get an error.
Error is:
‘T’ is not a template
T<T<char>>Board;
C++:
namespace board{
template <class T>
class BAdapter : public AbstractB{
public:
BAdapter();
BAdapter(int x){
x=6;
setSize(x);
}
virtual void setSize(int receivedSize){
int i,j;
Board.clear();
size=receivedSize;
Board.resize(getSize());
for(i=0; getSize()>i; i++){
Board[i].resize(getSize());
}
reset();
}
virtual bool loadGame(string fileName,char player,int game_mode){
fstream file;
int size2;
int i,j;
string line;
bool flag=false;
char state;
file.open(fileName);
if(file.is_open()){
file>>size2;
file>>player;
Board.clear();
Board.setSize(size2);
for(i=0; size2>i; i++){
file>>line;
for(j=0; size2>j; j++){
if(line[j]=='.'){
state='.';
}
else if(line[j]=='x'){
state='x';
}
else if(line[j]=='o'){
state='o';
}
Board[i][j].setRow(i);
Board[i][j].setColumn(j);
Board[i][j].set_cellState(state);
}
}
flag=true;
size=size2;
file.close();
}
return flag;
}
protected:
T<T<char>>Board;
};
}
Actually, I did not understand exactly what I was expected to do, but I get an error.
Error is:
‘T’ is not a template
T<T<char>>Board;
Last edited by a moderator: