I am trying to understand the Closed Graph Theorem and so I would like to see an example of an unbounded linear operator $\hat{T}: \mathscr{D}(\hat{T})\rightarrow Y$ where $\mathscr{D}(\hat{T})\subset X$ is a closed domain and $X$ and $Y$ are Banach spaces. In the Closed Graph theorem the domain $\mathscr{D}(\hat{T})$ and the graph $\mathscr{G}(\hat{T})$ must be closed and so I would like to see the necessity of $\mathscr{G}(\hat{T})$ being closed. The main doubt I have is if an unbounded linear operator is allowed to be defined in a closed domain.
Thanks.
Define $T(e_k)=kf$, where $\{e_k\}$ are linear independent in $X$ with $|e_k|=1$, and $f$ is a fixed nonzero vector in $Y$. For other $e$ that cannot represented by $\{e_k\}$, define $T(e)=0$. Then $T$ is defined on the whole space $X$, and it is obviously unbounded.