I was working on a small project a few months ago regarding an Instant Messaging application so I can give you a kick-start.
There is a protocol called xtensible Messaging and Presence Protocol (XMPP) witch is the most open sourced method of creating messaging applications.
There are several companies who use this technology for there applications one of witch is Google Talk and another is Facebook Chat
Most open source messaging applications use this protocol mainly within a C# environment (Which is the route we had taken)
As your main platform is going to be Desktop (Due to your C/C++ comment) i would advice you to get started with the C# Library AgsXMPP which comes under several languages but the main would be C# in my opinion.
Sample code from the main page:
XmppClientConnection xmpp = new XmppClientConnection("chat.facebook.com");
xmpp.Open("my", "password");
xmpp.OnLogin += delegate(object o)
{
Message Message = new Message("x.facebook.com",MessageType.chat, "Heya");
xmpp.Send(Message);
};
Hope this information helps you.