For many years, the classical guitar was considered the ideal instrument for all beginning guitarists. This was partly because the 'classical' tag conferred a degree of respectability, and also because many parents were rather scared of the prospect of noisy electric guitars and amps. This changed as baby boom children grew up with guitar-driven rock music, became parents (and then grandparents) themselves, and realised that headphones enable the electric guitar to be virtually silent to others at the same time as being extremely loud to the player.
In fact, the classical guitar is not ideal for learning to play rock music, which is inseparable from the sound of the electric guitar. Even a clean electric guitar sound is very different from that of the classical guitar, and the core rock sound (distortion) is completely different again. Rock players also make heavy use of string bending and wide vibrato, which are difficult or impossible to replicate on a nylon-strung instrument. Additionally, many lead guitar styles are based on unrestricted access right up the 22nd fret, whereas classical guitars rarely have more than 19 frets, and fast playing is impossible beyond the 12th.
The classical guitar is eminently suitable for a range of other styles though, from pure classical playing to finger-style jazz, folk, bossa nova and flamenco. The instrument also makes an important addition to the arsenal of any aspiring session player seeking to expand their sonic palette.
While many rock players are (at least initially) self-taught, the technicalities of classical guitar playing make this route less sensible - it's very easy to get into bad habits without a teacher!