Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Aiutttt
#include <iostream> #include <string> using namespace std; class StringSet { public: //COSTRUTTORE DI DEFAULT StringSet() { cout << "wee"; s = string[0] n_elem = 0; dim = 0; } bool contains(string x) { for(int i = 0; i < n_elem; ++i) { if(s[i] == x) return true; } return false; } void add(const string x) { cout << "contains\n"; if(!contains(x)) { if(n_elem == dim) { cout << "robe\n"; allarga(s, dim); } s[n_elem] = x; ++n_elem; } return; } private: string* s; int dim; int n_elem; void allarga(string* A, int& n) { string* tmp = new string[n + 2]; for(int i = 0; i < n; ++i) tmp[i] = A[i]; delete[] A; n += 2; A = tmp; return; } }; int main() { StringSet S1; S1.add("we"); }
run
|
edit
|
history
|
help
0
horse aand goat working
cynb
mergesort tree
Sorting Array
Making pyramid using nested loop 2/2
Gauss Jordan Ida
VecHotel
Wipro Problem 1
Template
KJ