﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-一沙一世界，一花一天堂-随笔分类-C++BUG</title><link>http://www.cppblog.com/lauer0246/category/9382.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 15 Jan 2009 07:49:43 GMT</lastBuildDate><pubDate>Thu, 15 Jan 2009 07:49:43 GMT</pubDate><ttl>60</ttl><item><title>cannot access private member </title><link>http://www.cppblog.com/lauer0246/archive/2009/01/15/72097.html</link><dc:creator>Robbin</dc:creator><author>Robbin</author><pubDate>Thu, 15 Jan 2009 07:36:00 GMT</pubDate><guid>http://www.cppblog.com/lauer0246/archive/2009/01/15/72097.html</guid><wfw:comment>http://www.cppblog.com/lauer0246/comments/72097.html</wfw:comment><comments>http://www.cppblog.com/lauer0246/archive/2009/01/15/72097.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lauer0246/comments/commentRss/72097.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lauer0246/services/trackbacks/72097.html</trackback:ping><description><![CDATA[class Time{<br>//public:<br>&nbsp; int hour, minute, second;<br>public:<br>&nbsp; void set(int h, int m, int s){ hour=h, minute=m, second=s; }<br>&nbsp; friend Time&amp; operator++(Time&amp; a);<br>&nbsp; friend Time operator++(Time&amp; a, int);<br>&nbsp; friend ostream&amp; operator&lt;&lt;(ostream&amp; o, const Time&amp; t);<br>};<br>使用自定义类时，编译提示错误：cannot access private member declared in class 'Time'<br>开始以为类定义时默认是私有变量，加上public，似乎可以解决问题<br>其实还是没有声明类引起的。<br><br><img src ="http://www.cppblog.com/lauer0246/aggbug/72097.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lauer0246/" target="_blank">Robbin</a> 2009-01-15 15:36 <a href="http://www.cppblog.com/lauer0246/archive/2009/01/15/72097.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>'operator &lt;&lt;' is ambiguous</title><link>http://www.cppblog.com/lauer0246/archive/2009/01/15/72095.html</link><dc:creator>Robbin</dc:creator><author>Robbin</author><pubDate>Thu, 15 Jan 2009 07:23:00 GMT</pubDate><guid>http://www.cppblog.com/lauer0246/archive/2009/01/15/72095.html</guid><wfw:comment>http://www.cppblog.com/lauer0246/comments/72095.html</wfw:comment><comments>http://www.cppblog.com/lauer0246/archive/2009/01/15/72095.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lauer0246/comments/commentRss/72095.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lauer0246/services/trackbacks/72095.html</trackback:ping><description><![CDATA[class Time{<br>public:<br>&nbsp; int hour, minute, second;<br>public:<br>&nbsp; void set(int h, int m, int s){ hour=h, minute=m, second=s; }<br>&nbsp; friend Time&amp; operator++(Time&amp; a);<br>&nbsp; friend Time operator++(Time&amp; a, int);<br>&nbsp; friend ostream&amp; operator&lt;&lt;(ostream&amp; o, const Time&amp; t);<br>};<br><br>自定义类中重载操作符后，调用时，编译提示错误：'operator &lt;&lt;' is ambiguous<br><br>解决方法：<br>VC6.0 需要先声明类和重载操作符<br>class Time;<br>ostream&amp; operator&lt;&lt;(ostream&amp; o, const Time&amp; t);<br>VC 6.0 在SP3之前, 对iostream与friend有Bug, 需要patch----SP5。可能这样的错误与编译器有关吧。<br><img src ="http://www.cppblog.com/lauer0246/aggbug/72095.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lauer0246/" target="_blank">Robbin</a> 2009-01-15 15:23 <a href="http://www.cppblog.com/lauer0246/archive/2009/01/15/72095.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>