/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include "Foo.h"
#include <iostream>
int main()
{
Foo * f1 = new Foo();
std::cout << "Foo's value is: " << f1->GetValue() << std::endl;
delete f1;
Foo * f2 = Foo::CreateFoo();
std::cout << "Foo's value is: " << f2->GetValue() << std::endl;
delete f2;
return 0;
}
#pragma once
class Foo
{
private:
int value;
static void Initialize();
public:
static Foo * CreateFoo();
Foo();
int GetValue();
};
#include "Foo.h"
#include <iostream>
void Foo::Initialize()
{
std::cout << "static void Foo::Initialize()" << std::endl;
}
Foo * Foo::CreateFoo()
{
std::cout << "static Foo * Foo::CreateFoo()" << std::endl;
return new Foo();
}
Foo::Foo()
{
std::cout << "Foo::Foo()" << std::endl;
value = 42;
}
int Foo::GetValue()
{
return value;
}