#include<iostre am>
using namespace std;
template <class T, int mway>
struct BNode
{
int noofKeys;
T keys[mway-1];
BNode<T, mway> *pointer[mway];
BNode();
};
template <class T,int mway>
class BST
{
public:
BST();
~BST();
int SearchRecord(T &toBeFound );
int Search(BNode<T, mway> *curNode,T toBeFound);
int Insert(const T &toBeAdded);
};
int main(int argc,char * argv)
{
typedef BST<int,30> mWayBST;
// typedef BST<int,argc> mWayBST;
mWayBST myBST;
int j = 9;
myBST.Insert(j) ;
myBST.Insert(10 );
myBST.Insert(6) ;
return 1;
}
I am new to template programming and I have a few doubts while coding.
Here above I have used template programming. This is for mWay Search tree.
Template has two parameters .... first is data type of the elements in the search tree and second is the integer order of tree itself....
Now the problem here is that I want to create an object of above class and the order(mWay) is given by user at runtime using arguments.
But an error occurs during compilation of commented line
// typedef BST<int,argc> mWayBST;
How this can be done ???
using namespace std;
template <class T, int mway>
struct BNode
{
int noofKeys;
T keys[mway-1];
BNode<T, mway> *pointer[mway];
BNode();
};
template <class T,int mway>
class BST
{
public:
BST();
~BST();
int SearchRecord(T &toBeFound );
int Search(BNode<T, mway> *curNode,T toBeFound);
int Insert(const T &toBeAdded);
};
int main(int argc,char * argv)
{
typedef BST<int,30> mWayBST;
// typedef BST<int,argc> mWayBST;
mWayBST myBST;
int j = 9;
myBST.Insert(j) ;
myBST.Insert(10 );
myBST.Insert(6) ;
return 1;
}
I am new to template programming and I have a few doubts while coding.
Here above I have used template programming. This is for mWay Search tree.
Template has two parameters .... first is data type of the elements in the search tree and second is the integer order of tree itself....
Now the problem here is that I want to create an object of above class and the order(mWay) is given by user at runtime using arguments.
But an error occurs during compilation of commented line
// typedef BST<int,argc> mWayBST;
How this can be done ???
Comment