#include <iostream>
#include <string>
#include <conio.h>
usingnamespace std;
template< class T >
class Set{
private:
//Cannot be negative number , validation
staticconst size_t N = 100;
T Item[N];
size_t count;
public:
Set() : count(0){};
~Set();
void addNewItem(const T &);
void RemoveItem(const T &);
size_t size();
size_t max_size();
int FindItem(const T &);
};
template< class T >
void Set<T> :: addNewItem( const T &item){
int result = FindItem(item);
//Add new item when FindItem return a value -1
if( result == -1 ){
}
else
cout << endl;//Nothing Happen
}
template< class T >
void Set<T> :: RemoveItem( const T &item ){
int result = FindItem(item);
if( result >= 0 && result < count ){
}
}
template< class T >
size_t Set<T> :: size() const{
return count;
}
template< class T >
size_t Set<T> :: max_size() const{
return N;
}
template< class T >
int Set<T> :: FindItem( const T &item ){
int result = -1;
for( int i = 0 ; i < count ; i++ ){
if( item == Item[i] ){
result = i;
break;
}
}
return result;
}
int main(){
int choice = 0;
string title;
system( "pause" );//Pause window
cout << "\tSet of items\n--------------------------" << endl
<< "1.Add New Item " << endl
<< "2.Remove an Item " << endl
<< "3.Number of items in the set " << endl
<< "4.Find Item " << endl
<< "5.Get all Items " << endl << endl
<< "Enter Choice : ";
cin >> choice;
switch( choice ){
case 1:{
cout << "Enter title : ";
getline( cin , title );
Set<string> set;
set.addNewItem(title);
break;
}
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
default:
cout << "Invalid Input ! Please re-enter ! "<< endl;
break;
}
system( "pause" );
return 0;//Exit program
}
this is my current code that done all.
but i haveing problem at
1 2 3 4 5 6 7 8 9 10 11
template< class T >
void Set<T> :: addNewItem( const T &item){
int result = FindItem(item);
//Add new item when FindItem return a value -1
if( result == -1 ){
}
else
cout << endl;//Nothing Happen
}
here ...
how should i add the value and increase which variable. faint...
sorry if I annoying you guys ><