1 // { dg-do run }
2 
3 extern "C" int printf(const char *, ...);
4 
5 class Environment {
6  public:
7   virtual ~Environment();
8 
9   // Static factory method that returns the implementation that provide the
10   // appropriate platform-specific instance.
11   static Environment* Create();
12 
13   // Gets an environment variable's value and stores it in |result|.
14   // Returns false if the key is unset.
15   virtual bool GetVar(const char* variable_name, char* result) = 0;
16 };
17 
18 class EnvironmentImpl : public Environment {
19  public:
GetVar(const char * variable_name,char * result)20   virtual bool GetVar(const char* variable_name, char* result) {
21       return true;
22   }
23 };
24 
~Environment()25 Environment::~Environment() {}
26 
27 // static
Create()28 Environment* Environment::Create() {
29   return new EnvironmentImpl();
30 }
31 
main()32 int main()
33 {
34   char * null = 0;
35   Environment * env = Environment::Create();
36   env->GetVar(0, null);
37   printf("%p\n", env);
38 }
39