help for add item ! Please

Hai. First time look over here..
Hope someone might help me..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <iostream>
#include <string>
#include <conio.h>

using namespace std;

template< class T >
class Set{
private:
	//Cannot be negative number , validation
	static const 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 ><
Do you understand how the data is being stored in the array?

If you do, then it should be rather easy to find the next open slot in the array to put the data in.
ya i know. but not really how to compare using the template.
mind to provide a simple simple code base on my place ?
really need help . sorry of it..
Topic archived. No new replies allowed.