super list2
Alexmegawin
c_cpp
2 years ago
641 B
8
Indexable
#include <iostream> using namespace std; class Nod { private: int number; public: Nod* nod_n; Nod(int num) { number = num; nod_n = nullptr; } }; class List { private: Nod* nod_1; int lenght; public: List() { nod_1 = nullptr; lenght = 0; } void create_nod(int num) { Nod* nod1 = new Nod(num); nod1->nod_n = nod_1; nod_1 = nod1; lenght++; } int delete_nod(Nod* nod1) { nod_1 = nod1->nod_n; delete nod1; lenght--; } int len() { return lenght; } }; int main() { List l; l.create_nod(5); cout << "lenght of list = " << l.len(); return 0; }
Editor is loading...