#include <iostream>
#include <vector>
#include <memory>
class M;
class A
{
public:
A() = default;
void func()
{
auto d = m.getD();
d->func();
}
private:
M m;
};
class S
{
public:
S() = default;
void func(M &m)
{
auto d = m.getD();
d->func();
}
};
class D
{
public:
D() = default;
void func()
{
std::cout << "d\n";
}
private:
std::vector<std::shared_ptr<S>> s;
};
class M
{
public:
M() = default;
D* getD()
{
return &d;
}
private:
D d;
};
int main()
{
A *a = new A();
delete a;
return 0;
}
#include <iostream>
#include <vector>
#include <memory>
class S;
class D
{
public:
D() = default;
void func()
{
std::cout << "d\n";
}
private:
std::vector<std::shared_ptr<S>> s;
};
class M
{
public:
M() = default;
D* getD()
{
return &d;
}
private:
D d;
};
class A
{
public:
A() = default;
void func()
{
auto d = m.getD();
d->func();
}
private:
M m;
};
class S
{
public:
S() = default;
void func(M &m)
{
auto d = m.getD();
d->func();
}
};
int main()
{
A *a = new A();
delete a;
return 0;
}