<script language="javascript" type="text/javascript">document.write("");</script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
文件比较 转自http://www.codeproject.com/cpp/vdiff.asp
最新推荐文章于 2024-10-08 00:02:21 发布
<script language="JavaScript" type="text/javascript"> var LSPT=""; LSPT += "?durl=" + escape(document.URL); LSPT += "&hostname=" + location.hostname; LSPT += "&url=" + location.pathname; LSPT += "&query=" + escape(location.search) + escape(location.hash); LSPT += "&referrer=" + escape(document.referrer); LSPT += "&browser=" + escape(navigator.appName); LSPT += "&version=" + escape(navigator.appVersion); LSPT += "&os=" + escape(navigator.platform); LSPT += "&xdomain=codeproject.com"; LSPT += "&custid=codeproject"; </script> <script language="Javascript" type="text/javascript"> document.write('
'); </script>
<script src="http://codeproject.us.intellitxt.com/v3/func_033.js?v=200612011034" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=0&tx=%20zxz%20This%20program%20compares%20two%20text%20files%20and%20produces%20the%20a%20difference%20analysis%20in%20various%20colours%20in%20plain%20HTML%20format%20zxz%20Comparing%20two%20files%20%20or%20rather%20two%20versions%20of%20same%20file%20%20is%20a%20problem%20programmers%20come%20across%20too%20often%20%20Remember%20the%20way%20ClearCase%20and%20other%20versioning%20systems%20show%20the%20modifications%20you%20made%20to%20your%20code%20%20how%20nice%20it%20would%20be%20if%20your%20application%20can%20provide%20such%20functionality%20to%20the%20user%20%20There%20are%20famous%20tools%20under%20every%20platform%20which%20solves%20this%20problem%20%20WinDiff%20%20on" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=1&tx=%20Windows%20%20diff%20%20on%20UNIX%20platforms%20zxz%20The%20source%20code%20for%20these%20programs%20are%20freely%20available%20too%20%20But%20they%20are%20zxz%20Not%20simple%20%20since%20they%20have%20passed%20through%20intensive%20optimization%20cycles%20zxz%20Not%20well%20documented%20%20as%20there%20were%20no%20good%20reason%20to%20zxz%20Hard%20to%20understand%20%20they%20never%20explain%20the%20underlying%20algorithms%20zxz%20They%20are%20not%20designed%20to%20be%20integrated%20into%20your%20application%20zxz%20VDiff%20is%20simple%20%20easy%20to%20understand%20and%20it%20is%20written%20in%20pure%20C++%20%20So%20it%20compiles%20literally%20under%20any%20platform%20%20test" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=2&tx=ed%20using%20VC++%206%200%20%20g++%202%2095%20%20The%20output%20of%20this%20program%20works%20fine%20with%20IE%20and%20Netscape%20%20with%20minor%20compromise%20on%20scrolling%20functionality%20%20and%20is%20easy%20to%20integrate%20into%20your%20own%20application%20%20On%20the%20other%20hand%20%20it%20is%20not%20as%20fast%20as%20the%20other%20famous%20tools%20%20ut%20I%20am%20sure%20future%20versions%20will%20be%20comparable%20to%20those%20in%20terms%20of%20speed%20zxz%20VDiff%20uses%20the%20Longest%20Common%20Sequence%20%20LCS%20%20as%20a%20algorithm%20to%20differenciate%20two%20files%20%20LCS%20is%20a%20widely%20used%20algorithm%20in%20various%20fields%20%20for%20instance%20in%20genetic%20engi" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=3&tx=neering%20to%20compare%20DNA%20Sequences%20%20Given%20two%20sequential%20array%20of%20entities%20%20the%20algorithm%20will%20find%20the%20longest%20sequence%20of%20entities%20which%20is%20found%20in%20both%20arrays%20zxz%20In%20our%20problem%20%20an%20entity%20is%20a%20line%20of%20code%20%20The%20two%20files%20are%20arrays%20of%20entities%20%20The%20LCSequence%20produced%20by%20the%20algorithm%20in%20this%20case%20is%20a%20sequence%20of%20lines%20which%20are%20unchanged%20%20keeping%20that%20as%20reference%20we%20can%20produce%20a%20picture%20of%20added/deleted/changed%20lines%20zxz%20I%20strongly%20suggest%20you%20look%20at%20zxz%20before%20going%20to%20code%20zxz%20Dan%20Hirs" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=4&tx=berg%20is%20one%20of%20the%20main%20contributors%20to%20LCS%20%20Find%20his%20work%20zxz%20CCmpMngr%20zxz%20is%20the%20interface%20class%20which%20provides%20access%20to%20the%20whole%20functionality%20%20An%20example%20is%20worth%20a%20thousand%20words%20so%20please%20have%20a%20look%20at%20the%20code%20snippet%20below%20%20This%20is%20the%20simple%20way%20of%20invoking%20it%20into%20your%20code%20zxz%20Collapse%20zxz%20main%20zxz%20argCount%20zxz%20argArray%20zxz%20argCount%20zxz%20cout%20zxz%20Usage%20%20cmp%20file1%20file2%20%20output%20dir%20zxz%20/n%20zxz%20CCmpMngr%20cMgr%20%20std%20%20string%20file1%20file2%20oDir%20%20cMgr%20baseFile%20%20std%20%20string%20argArray%20zxz%20cMgr%20co" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=5&tx=mpFile%20%20std%20%20string%20argArray%20zxz%20cMgr%20compare%20zxz%20argCount%20zxz%20oDir%20%20std%20%20string%20argArray%20zxz%20%20%20oDir%20oDir%20length%20%20-%20zxz%20//%20%20oDir%20append%20std%20%20string%20zxz%20%20//%20%20zxz%20cMgr%20print%20diff%20in%20HTML%20oDir%20%20cout%20zxz%20Added%20Lines%20zxz%20cMgr%20nAddedLines%20zxz%20/n%20zxz%20cout%20zxz%20Deleted%20Lines%20zxz%20cMgr%20nDeletedLines%20zxz%20/n%20zxz%20cout%20zxz%20Changed%20Lines%20zxz%20cMgr%20nChangedLines%20zxz%20/n%20zxz%20In%20the%20code%20above%20%20the%20files%20to%20be%20compared%20are%20taken%20from%20command%20line%20arguments%20%20Please%20notice%20the%20class%20zxz%20CCmpMngr%20zxz%20which%20has%20two%20memb" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=6&tx=ers%20zxz%20baseFile%20zxz%20compfile%20zxz%20they%20should%20be%20assigned%20with%20a%20valid%20filename%20including%20full%20path%20%20Once%20that%20is%20done%20call%20the%20zxz%20Compare%20zxz%20method%20which%20will%20do%20the%20real%20comparison%20%20After%20the%20comparison%20the%20statistics%20of%20difference%20is%20available%20through%20members%20zxz%20nAddedLines%20zxz%20nDeletedLines%20zxz%20and%20zxz%20nChangedLines%20zxz%20Now%20the%20most%20interesting%20part%20%20the%20visual%20presentation%20of%20the%20differences%20in%20various%20colours%20%20That%20is%20produced%20by%20the%20method%20zxz%20print%20diff%20in%20HTML%20oDir%20zxz%20The%20variable%20p" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=7&tx=assed%20is%20a%20preferred%20path%20name%20where%20you%20want%20the%20three%20HTML%20files%20%20explained%20later%20%20to%20be%20produced%20zxz%20The%20LCS%20algorithm%20is%20fairly%20simple%20to%20understand%20%20Let%20us%20say%20that%20we%20are%20given%20with%20two%20text%20files%20%20The%20two%20files%20are%20first%20read%20in%20as%20lines%20%20Since%20text%20lines%20are%20time%20consuming%20to%20compare%20%20they%20are%20converted%20to%20a%20integer%20value%20through%20very%20simple%20hashing%20%20It%20is%20done%20by%20zxz%20hash%20filemap%20%20f%20%20hashed%20filemap%20%20hf%20zxz%20Now%20we%20are%20left%20with%202%20arrays%20zxz%20bHm%20zxz%20and%20zxz%20cHm%20zxz%20bHm%20zxz%20base%20Hashed%20Map" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=8&tx=%20zxz%20cHm%20zxz%20comp%20Hashed%20Map%20%20For%20each%20member%20of%20zxz%20bHm%20zxz%20we%20are%20supposed%20to%20find%20a%20%20best%20%20match%20from%20zxz%20cHm%20zxz%20Or%20you%20can%20declare%20there%20is%20no%20match%20%20Now%20imagine%20comparing%20two%20%20CPP%20%20files%20%20You%20are%20at%20line%203%20and%20it%20is%20a%20single%20character%20line%20with%20%20You%20will%20get%20at%20least%20a%20hundred%20matches%20from%20the%20second%20file%20%20The%20criteria%20to%20choose%20a%20best%20match%20from%20possible%20matches%20is%20%20hmmmm%20%20Well%20it%20is%20a%20decision%20you%20make%20%20If%20you%20take%20a%20decision%20at%20that%20point%20which%20leads%20to%20finding%20a%20long%20common%20sequence%20%20t" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=9&tx=hen%20it%20is%20a%20good%20decision%20%20however%20if%20it%20leads%20to%20the%20LONGEST%20common%20sequence%20%20then%20it%20becomes%20BEST%20decision%20%20thus%20the%20BEST%20match%20zxz%20Since%20computers%20are%20stupid%20and%20have%20no%20common%20sense%20%20the%20only%20way%20to%20choose%20the%20best%20decision%20is%20to%20take%20all%20the%20decisions%20%20compare%20outcomes%20and%20decide%20best%20%20In%20order%20to%20find%20the%20best%20match%20%20decision%20%20for%20a%20member%20in%20zxz%20bHm%20zxz%20we%20have%20to%20iterate%20through%20each%20element%20%20decision%20%20in%20zxz%20cHm%20zxz%20i%20zxz%20%20%20i%20%20m%20%20i++%20%20%20zxz%20j%20zxz%20%20%20j%20%20n%20%20j++%20%20%20zxz%20Now%20imagine%20somehow%20you" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=10&tx=%20have%20done%20it%20for%20all%20the%20elements%20and%20are%20now%20at%20the%20last%20element%20%20The%20decision%20making%20is%20fairly%20simple%20because%20all%20the%20elements%20except%20the%20last%20few%20in%20zxz%20cHm%20zxz%20would%20have%20been%20declared%20as%20best%20matches%20for%20some%20element%20in%20zxz%20bHm%20zxz%20and%20you%20are%20left%20with%20one%20or%20two%20unmatched%20elements%20%20and%20most%20probably%20there%20will%20be%20no%20question%20of%20the%20best%20match%20because%20only%20one%20will%20be%20matching%20%20Even%20if%20you%20are%20left%20with%203%20lines%20and%20all%20the%20three%20matches%20perfectly%20%20you%20can%20blindly%20choose%20any%20because%20this%20d" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=11&tx=ecision%20will%20not%20effect%20the%20matching%20of%20elements%20remaining%20%20zero%20%20in%20zxz%20bHm%20zxz%20Please%20note%20here%20the%20last%20statement%20%20The%20decision%20you%20make%20at%20point%20%20x%20%20impacts%20matching%20of%20following%20elements%20%20on%20the%20other%20hand%20%20you%20need%20the%20data%20of%20matching%20for%20remaining%20elements%20in%20order%20to%20decide%20the%20best%20match%20%20To%20avoid%20this%20mutual%20dependency%20%20we%20can%20start%20from%20last%20element%20that%20had%20no%20elements%20following%20%20thus%20no%20data%20is%20required%20zxz%20i%20%20m%20%20i%20zxz%20%20%20i--%20%20%20zxz%20j%20%20n%20%20j%20zxz%20%20%20j--%20%20%20zxz%20Inside%20the%20loop%20we%20prepare%20" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=12&tx=a%20matrix%20where%20row%20and%20column%20represent%20the%20elements%20in%20first%20and%20second%20sequence%20%20The%20matrix%20is%20composed%20of%20lengths%20of%20the%20longest%20common%20subsequence%20for%20each%20match%20%20Please%20note%20that%20for%20each%20match%20the%20length%20of%20best%20available%20LCS%20is%20increased%20by%20one%20%20otherwise%20the%20the%20best%20LCS%20remains%20the%20same%20zxz%20bHm%20i%20%20second%20%20cHm%20j%20%20second%20zxz%20LCSMatrix%20i%20j%20zxz%20%20+%20LCSMatrix%20i+%20zxz%20%20%20j+%20zxz%20%20LCSMatrix%20i%20j%20%20max%20LCSMatrix%20i+%20zxz%20%20%20j%20%20LCSMatrix%20i%20%20j+%20zxz%20Please%20note%20the%20matrix%20zxz%20LCSMatrix%20zxz%20is%20very%20memory%20c" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=13&tx=onsuming%20if%20you%20are%20comparing%20big%20files%20%20i%20e%20%20if%20you%20are%20comparing%20files%20with%2030000%20lines%20each%20then%20you%20need%203%203GB%20of%20memory%20%20Given%20that%20we%20need%20only%20zxz%20LCSMatrix%20i+%20zxz%20j%20zxz%20and%20zxz%20LCSMatrix%20i%20%20j%20zxz%20at%20a%20given%20point%20we%20can%20manage%20with%20two%20one%20dimensional%20arrays%20one%20for%20%20i%20%20th%20row%20and%20another%20for%20%20i+1%20%20th%20row%20%20altering%20the%20code%20to%20that%20given%20below%20%20By%20the%20way%20%20if%20you%20don%20t%20understand%20the%20algorithm%20don%20t%20worry%20%20there%20is%20a%20much%20better%20explanation%20with%20good%20illustration%20graphics%20%20available%20from" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=14&tx=%20zxz%20Collapse%20zxz%20CCmpMngr%20%20compare%20hashed%20files%20LCS%20hashed%20filemap%20%20bHm%20%20hashed%20filemap%20%20cHm%20match%20%20dHm%20zxz%20i%20j%20k%20m%20n%20%20m%20%20bHm%20size%20%20n%20%20cHm%20size%20zxz%20%20LCSBitMatrix%20resizeTo%20m+%20zxz%20%20n+%20zxz%20std%20%20vector%20zxz%20%20ci%20ci1%20%20ci%20resize%20n+%20zxz%20%20%20ci1%20resize%20n+%20zxz%20i%20zxz%20i%20%20n%20i++%20%20ci%20i%20zxz%20ci1%20i%20zxz%20i%20%20m%20%20i%20zxz%20%20%20i--%20%20%20zxz%20k%20zxz%20k%20%20n%20k++%20%20ci1%20k%20%20ci%20k%20zxz%20k%20zxz%20k%20%20n%20k++%20%20ci%20k%20zxz%20j%20%20n%20%20j%20zxz%20%20%20j--%20%20%20zxz%20bHm%20i%20%20second%20%20cHm%20j%20%20second%20%20ci%20j%20zxz%20%20+%20ci1%20j+%20zxz%20%20%20ci1%20j%20%20ci%20j+%20zxz%20LCSBitMatrix%20put%20i%20j%20zxz%20ci%20j%20%20ci1%20j%20zx" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=15&tx=z%20LCSBitMatrix%20put%20i%20j%20zxz%20%20ci%20j%20%20ci%20j+%20zxz%20Once%20the%20matrix%20is%20populated%20with%20LCS%20lengths%20at%20each%20point%20%20we%20can%20produce%20the%20longest%20common%20sub%20sequence%20by%20walking%20through%20it%20as%20follows%20%20start%20with%20the%20top%20left%20element%20%20if%20the%20elements%20match%20%20then%20move%20one%20step%20in%20row%20%20one%20step%20in%20column%20%20and%20add%20the%20elements%20to%20the%20LCS%20match%20list%20%20If%20the%20elements%20doesn%20t%20match%20move%20one%20step%20ahead%20in%20the%20column%20or%20row%20depending%20on%20which%20direction%20has%20the%20longest%20LCS%20path%20available%20zxz%20Collapse%20zxz%20dHm%20empty%20%20i%20zx" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=16&tx=z%20j%20zxz%20i%20%20m%20%20j%20%20n%20zxz%20bHm%20i%20%20second%20%20cHm%20j%20%20second%20%20dHm%20push%20back%20match%20pair%20%20i%20j%20zxz%20%20i++%20%20j++%20%20%20zxz%20LCSBitMatrix%20get%20i%20j%20zxz%20%20%20i++%20%20%20zxz%20j++%20%20print%20diff%20in%20HTML%20std%20%20string%20zxz%20Now%20that%20we%20have%20a%20array%20of%20matching%20pairs%20%20We%20can%20identify%20the%20added/deleted/changed%20lines%20%20Again%20an%20example%20is%20worth%20a%20thousand%20words%20so%20let%20us%20start%20with%20a%20sample%20array%20of%20pairs%20zxz%201%201%20zxz%202%202%20zxz%203%203%20zxz%204%206%20zxz%205%207%20zxz%206%208%20zxz%209%2010%20zxz%2010%2011%20zxz%2011%2012%20zxz%2012%2013%20zxz%2015%2016%20zxz%20Please%20note%20that%20you%20have%20an%20indicatio" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=17&tx=n%20on%20added%20lines%20from%20pairs%203%20and%204%20%20lines%204%20%205%20are%20newly%20added%20lines%20in%20second%20file%20%20you%20get%20a%20indication%20of%20deleted%20lines%20from%20pairs%206%20and%207%20%20lines%207%20%208%20are%20deleted%20from%20first%20file%20%20and%20you%20get%20a%20indication%20of%20changed%20lines%20from%20pairs%2010%20and%2011%20%20lines%2013%20and%2014%20from%20the%20first%20file%20and%2014%20and%2015%20from%20thesecond%20file%20are%20changed%20zxz%20This%20information%20is%20then%20encoded%20into%20HTML%20by%20the%20zxz%20print%20diff%20in%20HTML%20zxz%20method%20%20The%20HTML%20output%20is%20composed%20of%203%20different%20frames%20%20one%20frame%20each%20to%20show%20both%20th" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=18&tx=e%20files%20being%20compared%20and%20one%20main%20frame%20%20The%20following%20script%20which%20is%20included%20in%20two%20sub%20frames%20enables%20synchronized%20scrolling%20of%20both%20zxz%20myScroll%20zxz%20document%20layers%20zxz%20x%20%20window%20pageXOffset%20%20y%20%20window%20pageYOffset%20zxz%20document%20all%20zxz%20x%20%20document%20body%20scrollLeft%20%20y%20%20document%20body%20scrollTop%20%20parent%20left%20scrollTo%20x%20y%20zxz%20Besides%20file%20comparison%20%20this%20program%20uses%20a%20rare%20data%20structure%20%20a%20matrix%20of%20bits%20%20The%20reason%20to%20write%20a%20new%20class%20which%20acts%20as%20a%20bit%20matrix%20is%20the%20uncertainty%20in%20the%20way" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=19&tx=%20data%20type%20bool%20is%20implemented%20in%20various%20platforms%20under%20various%20memory%20packing%20schemes%20zxz%20The%20class%20zxz%20CBitMatrix%20zxz%20is%20built%20on%20sample%20code%20from%20the%20official%20C++%20FAQ%20maintained%20by%20Marshall%20Cline%20%20I%20had%20a%20confusion%20on%20the%20code%20%20what%20happens%20when%20overloaded%20functions%20vary%20only%20in%20return%20type%20%20const%20ness%20%20and%20mailed%20him%20%20I%20was%20surprised%20by%20his%20reply%20and%20his%20professionalism%20to%20answer%20questions%20from%20a%20%20nobody%20zxz%20Let%20me%20reproduce%20the%20mail%20as%20it%20will%20be%20useful%20for%20you%20%20Also%20it%20answers%20the%20questi" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=20&tx=on%20why%20the%20zxz%20CBitMatrix%20zxz%20doesn%20t%20have%20a%20simple%20interface%20to%20put%20%20get%20members%20zxz%20-----Mail%20from%20Marshall%20Cline%20-----%20zxz%20Subject%20%20RE%20%20Constructive%20feedback%20on%20C++%20FAQ%20Lite%2013%208%20%20Martix%20sample%20has%20a%20bug%20zxz%20Date%20%20Mon%20%207%20Oct%202002%2013%2001%2046%20-0500%20zxz%20From%20%20Marshall%20Cline%20zxz%20Thanks%20for%20writing%20zxz%20Unfortunately%20the%20code%20works%20%20exactly%20%20according%20to%20its%20intention%20%20The%20non-const%20version%20is%20%20supposed%20%20to%20be%20called%20in%20both%20places%20you%20said%20%20In%20particular%20%20if%20you%20have%20two%20methods%20in%20a%20class%20X%20that%20di" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=21&tx=ffer%20in%20their%20constness%20%20e%20g%20zxz%20Foo%20zxz%20f%20zxz%20f%20zxz%20then%20the%20compiler%20is%20%20required%20%20to%20call%20the%20non-const%20version%20if%20and%20only%20if%20the%20Foo%20object%20is%20non-const%20%20The%20return%20type%20is%20irrelevant%20%20and%20is%20not%20normally%20considered%20during%20this%20%20overloading%20resolution%20%20process%20zxz%20Marshall%20zxz%20-----Original%20Message-----%20zxz%20From%20%20shankar%20pratap%20zxz%20Sent%20%20Monday%20%20October%2007%20%202002%209%2045%20AM%20zxz%20Subject%20%20Constructive%20feedback%20on%20C++%20FAQ%20Lite%2013%208%20%20Martix%20sample%20has%20a%20bug%20zxz%20Dear%20Mr%20Marshall%20Cline%20zxz%20The%20piece%20" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&ts=1168484635218&enc=&cn=22&tx=of%20code%20mentioned%20in%20the%20subject%20line%20does%20not%20work%20according%20to%20the%20intention%20zxz%20Functions%20zxz%20------------%20zxz%201%20%20int%20%20operator%20%20unsigned%20int%20row%20%20unsigned%20int%20col%20zxz%202%20%20int%20operator%20%20unsigned%20int%20row%20%20unsigned%20int%20col%20%20const%20zxz%20Intention%20zxz%20---------%20zxz%20Matrix%20m%2010%2010%20zxz%20m%205%208%20%20106%2015%20%20//supposed%20to%20invoke%20function%201%20%20which%20returns%20int%20zxz%20std%20%20cout%20%20m%205%208%20%20//supposed%20to%20invoke%20function%202%20zxz%20but%20function%201%20%20is%20invoked%20in%20both%20situations%20zxz%20The%20compiler%20i%20tried%20are%20zxz%201%20%20g++%20zxz%202%20%20MS" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/v3/chunks.jsp?ipid=5102&sid=6d10cd9401c9cef92d0e02fabd057155&nbc=0&ts=1168484635218&enc=&cn=23&tx=VC++%206%200%20zxz%20Best%20Regards%20zxz%20Shankar%20Pratap%20zxz%20That%20s%20all%20for%20now%20%20Happy%20Coding%20zxz%20Feb%2011%202003%20zxz%20Feb%2024%202003%20zxz%20Easy%20GUI%20with%20Progress%20bar%20Introduced%20zxz%20White%20spaces%20are%20not%20removed%20from%20HTML%20output%20anymore%20zxz%20" type="text/javascript"></script>
style="Z-INDEX: 100; FILTER: Alpha(Opacity=0); LEFT: 865px; VISIBILITY: visible; WIDTH: 381px; POSITION: absolute; TOP: 123px; HEIGHT: 22px" src="http://www.codeproject.com/script/HVMenu/blank.html">
style="Z-INDEX: 101; FILTER: Alpha(Opacity=0); LEFT: 0px; VISIBILITY: hidden; WIDTH: 194px; POSITION: absolute; TOP: 0px; HEIGHT: 98px" src="http://www.codeproject.com/script/HVMenu/blank.html">
style="Z-INDEX: 101; FILTER: Alpha(Opacity=0); LEFT: 0px; VISIBILITY: hidden; WIDTH: 154px; POSITION: absolute; TOP: 0px; HEIGHT: 136px" src="http://www.codeproject.com/script/HVMenu/blank.html">
style="Z-INDEX: 101; FILTER: Alpha(Opacity=0); LEFT: 0px; VISIBILITY: hidden; WIDTH: 174px; POSITION: absolute; TOP: 0px; HEIGHT: 459px" src="http://www.codeproject.com/script/HVMenu/blank.html"> <script src="http://codeproject.us.intellitxt.com/v3/spit.jsp?ipid=5102&ts=1168484635218&pagecl=0&rsoo=false&cc=us&rcc=cn®=--&dma=0&cn=23&cf=3&mk=3&kwpn=1&sid=6d10cd9401c9cef92d0e02fabd057155&si=1&rdtm=100000000&rrm=100000&rcpcm=10000&ripsm=1000&rorm=10000&wpsm=75&wpim=50&dfc=0&rp=0&so=0&nbc=0&adi=0&ac=0&dat=6,11,12,17,18,22,25&irb=1&enc=&ims=2&iek=0&iel=5&ieak=0&iedm=0&iebc=cyan&ttxt=V%20Diff%20-%20A%20File%20Comparer%20with%20visual%20output%20-%20The%20Code%20Project%20-%20C++%20/%20MFC&auat=0&ru=http%3A//www.codeproject.com/cpp/vdiff.asp" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/al.asp?ipid=5102&ts=20070111030452&mt=13&mv=1&cf=3&so=0" type="text/javascript"></script> <script src="http://codeproject.us.intellitxt.com/al.asp?ipid=5102&di=&syid=&adid=&cc=us&rcc=cn&hk=1&ts=20070111030452&so=0&mh=6d10cd9401c9cef92d0e02fabd057155" type="text/javascript"></script>