One summer afternoon a friend confided in me that she was five months' pregnant. "Of course you are," I said, staring at the sizeable bump which, until that second, I simply hadn't seen. I felt much the same when Albus Dumbledore, headmaster of Hogwarts School and all-round hero, was brought out of the closet, in Carnegie Hall, by his creator, J K Rowling.

Should she have done it?

Well, of course Dumbledore was gay. Just think of the robes, the exotic hats, the fabulous seasonal decorations for sumptuous school feasts. Dumbledore had lived for aeons yet there was never a hint of a former Mrs Dumbledore or any scintilla of flirtation with an eye-batting witch. His life was dedicated to his school, to the children within it and to the achievement of a world where justice and tolerance ruled supreme.

For all his virtues, however, there were those in the wizarding world who briefed against him. There were persistent questions from some about his suitability to be headmaster of Hogwarts School of Witchcraft and Wizardry and the stuffed-shirted bureaucrats from the Ministry of Magic always had an unspecified down on him. It's true that he was anarchic, irreverent and unconventional but there lingered a sense that there was some other objection that remained unspoken.

How many headmasters, army officers, bishops and judges in the real world must have lived a similarly upstanding but perilous existence; forever dutiful and forever teetering on the brink of personal exposure and public censure? How many still do? How many teenagers are discovering they prefer their own sex and finding it difficult to come to terms with? In Dumbledore, Rowling has given them a champion of unimpeachable virtue. The headmaster's only slip in a life many multiples of the natural span was a loss of judgment when he was in the grip of a youthful infatuation.

A homosexual Dumbledore is all of a piece with Rowling's declared determination to make her novels, "a prolonged argument for tolerance".

Harry himself is a despised orphan. His two closest friends are Ron and Hermione; Ron is poor and Hermione is of mixed blood. Harry's girlfriend is Chinese and his school friends hail from Indian or Irish stock. His saviour, Hagrid, is half-giant, his godfather is a reviled prisoner and those on the side of righteousness include a werewolf and a scar-faced wizard with a wooden leg and a rotating glass eye.

She could have written on the flyleaves of her books: Bring me your tired, your poor, your huddled masses . . .' The one social category in need of cheering up and championing that is not in the books is the gay community. It was not, however, conspicuous by its absence, probably because the Potter books are written for children as well as those who never grow up.

So what would wise Albus Dumbledore have made of his posthumous outing? Would he have thought the time had come for Harry and his friends to understand the whole truth about him? Since not even wizards can return from the dead, we, too, will die and never know. Since the same Albus Dumbledore is a figment of Rowling's imagination, reactions to the late, non-existent wizard's sexual orientation grows "curiouser and curiouser". Gay rights activist Peter Tatchell feels characteristically sold short. It would have been better to declare Dumbledore's gayness in the Harry Potter books, he says. Stonewall, the organisation working for equality and justice for lesbians, gay men and bisexuals, is happier: "This shows there are no limits to what gay and lesbian people can do - even be a wizard headmaster," its spokesman says.

But, as the charismatic Hogwarts headmaster fell to his death in the closing chapters of Harry Potter and the Half-Blood Prince, there will be many parents who will applaud his decision to take the detail of his sexuality with him. They will wish that Rowling, too, had left it unspoken.

Some will be of the Section 2A mindset; people who imagine that the mention of homosexuality causes its spread. Had Rowling declared that Dumbledore was gay before the final books were printed, they might have boycotted her multi-million pound sell-out editions - and their children would have been reduced to Harry-like disobedience in their pursuit of a farewell read.

But a wider section of parents will also regret Rowling's declaration. "Is it really necessary to ascribe any sexual orientation to Dumbledore?", they will be asking. They have a point. The characters in Rowling's books are judged by just that: their character. Looks count for little or nothing, brains are admired but only in the good-hearted, wealth is often the preserve of the evil and snootiness of any description is despised. In these books, the stresses that real children face in their everyday school life, such as examination league tables and obligatory slenderness, are turned on their heads. The message to child readers is that moral fibre, a sense of justice and a willingness to fight for it, is the true measure of greatness.

Until this declaration of Dumble- dore's sexual orientation, Potter books were a reminder of a more innocent time. Yes, they contain evil and death and lots of derring-do. What they are devoid of is any sexuality beyond a romantic teenage crush. Harry and his friends pursue chaste romances; Hagrid gets swoony about a female giant. As a result, the books can be read at nine or 90.

Rowling might argue that Dumbledore's unfortunate crush on the dark wizard Gellert Grindelwald falls into the same category as Harry's infatuation with Cho Chang. It's true that it isn't written up as anything more than an intense friendship between young men. The only hint of anything more is in Grindelwald's ability partially to persuade the righteous Dumbledore temporarily to support his fascistic views. Still, the world did not spot that Dumbledore was "smitten" until Rowling said so publicly. "Dumbledore's love for Grindelwald was his great tragedy," she revealed.

Well, the cat is well and truly out of the bag now. Like every writer, Rowling has a back story for her fictional characters and - unlike Noddy and Big Ears - there can never more be any doubt about Dumbledore. On balance, I think his gayness is a good thing and its revelation has been cleverly executed. First, Rowling built the character layer by layer. She built him to be the acme of all that is wise and kind; dutiful and virtuous. She put him in a position of trust; headmaster of a mixed boarding school. She made him a champion of the underdog and a protector of the excluded. She even killed him off in a final heroic act of self-sacrifice. And having placed him as far beyond criticism as her fertile imagination would allow; abracadabra - she revealed that he was gay.

Let the prejudiced, the gay bashers, the bigots try as they might; they won't be able to tear this icon off his pedestal. Rowling has held a literary mirror to their narrow-mindedness to let them see for themselves how purposefully blind it is. And as they wrestle with the invisible knots she has tied them in, they'll hear, if they listen, her metaphorical laughter. It's the laughter of a Pied Piper as she leads their spellbound children to the broad sunny uplands of tolerance.