c++中的单态模式。(就是不知道为什么用typedef)

来源:互联网 发布:程序员工资真的很高吗 编辑:程序博客网 时间:2024/06/05 11:23
// Array.cpp : Defines the entry point for the console application.   //     #include "stdafx.h"   #include <stdio.h>   #include <iostream.h>     class A{          typedef A* PA;   private:          static  const PA pa;          A(){}   public:          static const PA GetA(){            return pa;          }          void hello() const {                cout<<"Hello!"<<endl;          }             };   const A::PA A::pa=new A();   //const static  A  pa;     int main(int argc, char* argv[])   {       A* pa=A::GetA();       pa->hello();   }  

原创粉丝点击