1 #define NULL 0
 2 #include <iostream>
 3 
 4 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 5 using namespace std;
 6 class String
 7 {
 8     public:
 9         String(){
10             p=NULL;
11         }
12         String(char *str);
13         void display();
14     private:
15         char *p;
16 };
17 
18 String::String(char *str)
19 {
20     p=str;
21 }
22 
23 void String::display()
24 {
25     cout<<p;
26 }
27 
28 int main(int argc, char** argv) {
29     String string1("Hello"),string2("Book");
30     string1.display();
31     cout<<endl;
32     string2.display();
33     return 0;
34 }

 

相关文章:

  • 2022-02-08
  • 2022-02-14
  • 2021-12-28
  • 2021-10-08
猜你喜欢
  • 2021-11-18
  • 2022-12-23
  • 2021-09-20
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案