//Student register Program
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <string>
usingnamespace std;
template <typename DT>
class studentRegister
{
private:
struct Node
{
Node * left;
Node * right;
<DT> data;
};
Node * root;
public:
studentRegister()
{
root = NULL;
}
bool isEmpty() const { return root==NULL; } //inline function
void insert(DT);
};
// Smaller elements go left
// larger elements go right
void studentRegister::insert(DT)
{
Node * t = new Node ;
Node * parent;
t->data = d;
t->left = NULL;
t->right = NULL;
parent = NULL;
// is this a new tree?
if(isEmpty()) root = t;
else
{
//Note: ALL insertions are as leaf nodes
Node* curr;
curr = root;
// Find the Node's parent
while(curr)
{
parent = curr;
if(t->data > curr->data) curr = curr->right;
else curr = curr->left;
}
if(t->data < parent->data)
parent->left = t;
else
parent->right = t;
}
}
int main()
{
studentRegister reg;
int ch;
string name;
while(1)
{
cout<<endl<<endl;
cout<<" Student Register Operations "<<endl;
cout<<" ----------------------------- "<<endl;
cout<<" 1. Insertion/Creation "<<endl;
cout<<" 2. Exit "<<endl;
cout<<" Enter your choice : ";
cin>>ch;
switch(ch)
{
case 1 : cout<<" Enter Number to be inserted : ";
cin>>name;
reg.insert(name);
break;
case 2 :
return 0;
}
}
}
I get the following errors:
------ Build started: Project: assignment, Configuration: Debug Win32 ------
Compiling...
binarytree.cpp
binarytree.cpp(17) : error C2059: syntax error : '<'
binarytree.cpp(14) : see reference to class template instantiation 'studentRegister<DT>::Node' being compiled
binarytree.cpp(30) : see reference to class template instantiation 'studentRegister<DT>' being compiled
binarytree.cpp(17) : error C2238: unexpected token(s) preceding ';'
inarytree.cpp(34) : error C2955: 'studentRegister' : use of class template requires template argument list
binarytree.cpp(11) : see declaration of 'studentRegister'
binarytree.cpp(34) : error C2065: 'DT' : undeclared identifier
binarytree.cpp(35) : error C2448: 'studentRegister<DT>::insert' : function-style initializer appears to be a function definition
binarytree.cpp(70) : error C2133: 'reg' : unknown size
binarytree.cpp(70) : error C2512: 'studentRegister' : no appropriate default constructor available
binarytree.cpp(87) : error C2662: 'studentRegister<DT>::insert' : cannot convert 'this' pointer from 'studentRegister' to 'studentRegister<DT> &'
Reason: cannot convert from 'studentRegister' to 'studentRegister<DT>'
Conversion requires a second user-defined-conversion operator or constructor
where am i going wrong??
feedback will be very much appreciated