Let the height of the building be \( h_1 = 10 \, \text{m} \). Let the height of the flagpole be \( h_2 \) meters. The total height from point \( P \) to the top of the flag will be \( h_1 + h_2 \).
Step 1: Use the angle of elevation to the building.
We are given that the angle of elevation of the building from point \( P \) is 30°. This forms a right-angled triangle
where:
- The opposite side is the height of the building \( h_1 = 10 \, \text{m} \),
- The angle of elevation is \( 30^\circ \),
- The adjacent side is the distance from point \( P \) to the building, denoted as \( d \).
Using the tangent function:
\[
\tan 30^\circ = \frac{h_1}{d} = \frac{10}{d}
\]
Since \( \tan 30^\circ = \frac{1}{\sqrt{3}} \), we have:
\[
\frac{1}{\sqrt{3}} = \frac{10}{d}
\]
Solving for \( d \):
\[
d = 10 \sqrt{3} \approx 17.32 \, \text{m}
\]
Step 2: Use the angle of elevation to the top of the flag.
Next, we are given that the angle of elevation to the top of the flag is 45°. This forms another right-angled triangle
where:
- The opposite side is the total height \( h_1 + h_2 = 10 + h_2 \),
- The angle of elevation is \( 45^\circ \),
- The adjacent side is the same distance \( d = 17.32 \, \text{m} \).
Using the tangent function again:
\[
\tan 45^\circ = \frac{h_1 + h_2}{d} = \frac{10 + h_2}{17.32}
\]
Since \( \tan 45^\circ = 1 \), we have:
\[
1 = \frac{10 + h_2}{17.32}
\]
Solving for \( h_2 \):
\[
10 + h_2 = 17.32 \quad \Rightarrow \quad h_2 = 17.32 - 10 = 7.32 \, \text{m}
\]
Conclusion:
The length of the flagpole is \( \boxed{7.32} \, \text{m} \) and the distance of point \( P \) from the building is \( \boxed{17.32} \, \text{m} \).