home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / TEXT / COMMONC.3 < prev    next >
Encoding:
Text File  |  1993-11-06  |  730 b   |  18 lines

  1. %F,15,COMMONC.MNU%Constructs_in_C_and_C++ / %F,15,COMMONC.2%Previous / %F,15,COMMONC.4%Next
  2.  
  3.                %C,1%Class and typedef Names
  4.  
  5. In C++, a class and a %C,1%typedef%C,5% cannot both use the same name
  6. to refer to a different type within the same scope (unless
  7. the %C,1%typedef%C,5% is a synonym for the class name).  In C, a
  8. %C,1%typedef%C,5% name and a %C,1%struct%C,5% tag name declared in the same
  9. scope can have the same name because they have different name
  10. spaces.  For example:
  11.  
  12.   %C,1%void %C,5%main %C,1%() {
  13.     %C,1%typedef double %C,5%db%C,1%;
  14.     %C,1%struct %C,5%db%C,1%;%C,14% // error in C++, valid in ANSI C
  15.     %C,1%typedef struct %C,5%st st%C,1%;%C,14% // valid ANSI C and C++
  16.   %C,1%}
  17.  
  18.