面向对象程序第二课c++基础.pptVIP

  • 4
  • 0
  • 约8.93千字
  • 约 53页
  • 2017-08-14 发布于河南
  • 举报
C++基础入门 变量与类型的附加知识 ◆标识符的作用域 ◆Const限定符 ◆引用 ◆typedef ◆作用域问题 大多数作用域问题都很简单,就是用大括号。 全局作用域(global scope) 局部作用域(local scope) 作用域嵌套 #include iosteam #include string std::string s1 = “hello”; //s1 has global scope int main() { std::string s2 = “world”; //s2 has local scope //uses global s1; prints “hello world” std::cout s1 “ “ s2 std::endl; int s1 = 42; // s1 is local and hides global s1 //uses local s1; prints “42 world” std::cout s1 “ “ s2 std::endl; return 0; } #include iosteam.h int avar = 10; void main() { int avar; avar = 20; ::avar = 30; //

文档评论(0)

1亿VIP精品文档

相关文档