Here's an example that's a 2-dimensional CW complex. Start with a 0-cell, then attach three 1-cells labeled $a$, $b$, $c$ to get a wedge of three circles, then attach a 2-cell via the word $aba^{-1}b^{-1}c^n$ for a fixed integer $n>1$. From the cellular cochain complex one then reads off that the resulting complex $X$ has $H^1X={\mathbb Z}\times{\mathbb Z}$ with generators $a$ and $b$ (by abuse of notation) and $H^2X={\mathbb Z}_n$. The claim is that $a\cup b$ is a generator of $H^2X$. To see this consider the quotient space of $X$ obtained by collapsing the 1-cell $c$ to a point. This is a torus $T$ and the quotient map $X\to T$ induces an isomorphism on $H^1$ and a surjection on $H^2$, as one can see by looking at the induced map on cellular chain complexes. In $T$ the cup product $a\cup b$ generates $H^2$ so the same is true for $X$ by naturality of cup product. When $n=2$ the complex $X$ is a closed surface since it's a hexagonal 2-disk with edges identified in pairs. Its Euler characteristic is $-1$ so it's the connected sum of a torus and the real projective plane.