📄 example.cc
字号:
// file: $isip/doc/examples/class/dstr/dstr_example_01/example.cc// version: $Id: example.cc,v 1.2 2000/12/17 17:53:55 hamaker Exp $//// isip include files//#include <String.h>#include <DoubleLinkedList.h>// main program starts here:// this example produces a linked list of randomly generated nonsense strings// note that the linked list has two modes - USER and SYSTEM.// we use USER mode here to demonstrate the way that memory can be// controlled by the user while still taking advantage of our dstr// classes//int main() { // declare a USER mode DoubleLinkedList // DoubleLinkedList<String> list_string(DoubleLinkedList<String>::USER); // add 10 randomly generated strings, all with lengths on the range [5,20], // to the linked list // for (long i = 0; i < 10; i++) { // generate the random string // String* tmp_str = new String(); tmp_str->rand(5,20); // add the random string to the list. this inserts at the current location // and changes the current location to be this item. // list_string.insert(tmp_str); } // display the contents of the list // list_string.debug(L"list of random strings"); // free the memory allocated for the list // String* tmp_str = (String*)NULL; while (list_string.removeFirst(tmp_str)) { delete tmp_str; } // exit gracefully // Integral::exit();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -