Step 1: Let the height of the flag be $h$ metres.
Then, total height of the building and flag = $(10 + h)$ m.
Step 2: Draw a right-angled triangle.
Let the distance of point P from the base of the building be $x$ m.
From the figure (mentally imagined):
- $\triangle PAB$ represents the building top, and
- $\triangle PAC$ represents the top of the flag.
Step 3: Use trigonometric ratios.
From $\triangle PAB$:
\[
\tan 30° = \frac{\text{height of building}}{\text{distance}} = \frac{10}{x}
\Rightarrow x = \frac{10}{\tan 30°}
\Rightarrow x = \frac{10}{\frac{1}{\sqrt{3}}} = 10\sqrt{3}
\]
Step 4: From $\triangle PAC$:
\[
\tan 45° = \frac{\text{total height}}{\text{distance}} = \frac{10 + h}{x}
\]
Substitute $x = 10\sqrt{3}$ and $\tan 45° = 1$:
\[
1 = \frac{10 + h}{10\sqrt{3}}
\Rightarrow 10 + h = 10\sqrt{3}
\]
\[
h = 10(\sqrt{3} - 1)
\]
Step 5: Approximate value (if needed).
Since $\sqrt{3} \approx 1.732$,
\[
h = 10(1.732 - 1) = 10(0.732) = 7.32 \, \text{m}
\]
Step 6: Conclusion.
Hence, the length of the flag is
\[
\boxed{h = 10(\sqrt{3} - 1)\ \text{metres} \ (\approx 7.32 \text{ m})}
\]