11.1错误包括.docVIP

  • 1
  • 0
  • 约2.98千字
  • 约 8页
  • 2017-12-11 发布于江苏
  • 举报
11.1错误包括

11.1 错误包括: 1.??? 类定义体的结束要加分号: class Point { ... }; 2.??? main函数中,不能直接访问类Point对象的保护成员x和y。所以下面两句不对。 p.x += 5; p.y += 6; 3.??? 倒数第二行的endl前面应没有双引号(可能是印刷错误)。 11.2 可以将程序分为下面三个文件 : //文件cat.h class Cat { ...... }; //文件cat.cpp #include iostream.h #include cat.h int Cat::GetAge() { return itsAge; } int Cat::SetAge(int age) { itsAge = age; } void Cat::Meow() { cout Meow. \n; } //文件main.cpp #include iostream.h #include cat.h void main() { ...... } 程序的运行结果为: Meow. Frisky is a cat who is 5 years old. Meow. 11.3 #include iostream.h int dayOfMonth[12] = {31,2

文档评论(0)

1亿VIP精品文档

相关文档