2004-01-07 Michael Chastain <mec.gnu@mindspring.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / bs15503.cc
CommitLineData
7be570e7
JM
1#include <string>
2#include <iostream.h>
3
4template <class T>
5class StringTest {
6public:
7 virtual void runTest();
8 void testFunction();
9};
10
11template <class T>
12void StringTest<T>:: runTest() {
13 testFunction ();
14}
15
16template <class T>
17void StringTest <T>::testFunction() {
18 // initialize s with string literal
19 cout << "in StringTest" << endl;
20 string s("I am a shot string");
21 cout << s << endl;
22
23 // insert 'r' to fix "shot"
24 s.insert(s.begin()+10,'r' );
25 cout << s << endl;
26
27 // concatenate another string
28 s += "and now a longer string";
29 cout << s << endl;
30
31 // find position where blank needs to be inserted
32 string::size_type spos = s.find("and");
33 s.insert(spos, " ");
34 cout << s << endl;
35
36 // erase the concatenated part
37 s.erase(spos);
38 cout << s << endl;
39}
40
41int main() {
42 StringTest<wchar_t> ts;
43 ts.runTest();
44}
45
46/* output:
47I am a shot string
48I am a short string
49I am a short stringand now a longer string
50I am a short string and now a longer string
51I am a short string
52*/
This page took 0.382332 seconds and 4 git commands to generate.