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