Question: Let $X$ be a compact topological space with continuous map $f\colon X\to X$. $Y:=\bigcap\_{n\in\mathbb{N}}f^n(X)\subseteq X$ is closed and hence compact itself. 

Assume $\overline{A}=Y$, i.e. $A$ is be dense in $Y$.

Does this imply $\overline{A}=X$, i.e. that $A$ is dense in $X$?

Answer: 
No it does not. For a counterexample take $Y = [0, 1]$ and $X = [-1, 2]$ as subsets of $\mathbb{R}$ (where $\mathbb{R}$ has the standard topology). Note that $X$ is compact and $Y \subseteq X$ and $Y$ is closed and thus also compact. Then let $A = (0, 1) \subseteq Y \subseteq X$. 

Then we have $\overline{A} = Y$ and certainly $\overline{A} = [0, 1] \neq [-1, 2] = X$.
Lemma: Given $A\subseteq Y \subseteq X$, where $X$ is a topological space and $Y$ is endowed with the sub-space topology. Then the closure of $A$ in $Y$ is the intersection with $Y$ of the closure of $A$ in $X$: $$\overline{A}^Y=\overline{A}^X\cap Y$$

From this lemma it follows that we can speak about $\overline{A}$ without confusion.

If $Y\neq X$ is closed in $X$, then $\overline A\subseteq Y\neq X$ so no subset of $Y$ can be dense in $X$.

---

Proof of Lemma: $\overline{A}^X\cap Y$ is closed in $Y$, hence $\overline{A}^Y\subseteq \overline{A}^X\cap Y$ (because $\overline{A}^Y$ is the smallest closed subet of $Y$ containing $A$). 

On the other hand, sinche $\overline{A}^Y$ is closed in $Y$, and $Y$ is endowed with the subspace topology, then there is a closed subset $C$ of $X$ such that $\overline{A}^Y=C\cap Y$. As above, since $C$ is closed in $X$, we have $\overline{A}^X\subseteq C$, whence $\overline{A}^X\cap Y\subseteq C\cap Y=\overline{A}^Y$. 

Since $\overline{A}^Y\subseteq \overline{A}^X\cap Y\subseteq \overline{A}^Y$, both inclusions are in fact equalities. $\square$