Can I use CPVC to make a solar water heaer?
Sunlight resistance is not a problem if you're going to be painting it anyway.
The real problem is temperature. You're not clear as to how you intend to design the system, but, unless you take specific measures to prevent overheating (e.g. by having a pump that turns on and flushes pipes periodically), pipes can get very hot. Solar heaters are traditionally copper, which can handle boiling water just fine. On the other hand, CPVC is only rated up to about 200 F. Maximum temperature varies depending on pressure and pipe dimensions, but, generally speaking, at 200 F, CPVC piping is barely strong enough to withstand normal water-main pressure. ("Hot water" inside your house is rarely hotter than 140 F.) Other plastics are as bad or even worse (e.g. ABS and PVC are both rated for lower temps than CPVC and PEX).
The link in the other answer suggests that PEX might handle 230 F, but it depends on your system (I don't see any pipe dimensions there).