小编r_d*_*uck的帖子

Rust 中同一范围内的变量阴影?

fn main() {
    let x = 5;
    println!("{}", x);

    let x = 3.14;
    println!("{}", x);

    let x = "Hello";
    println!("{}", x);
}
Run Code Online (Sandbox Code Playgroud)
  1. 以前的值会发生什么变化?我的理解是它们没有被破坏。

  2. 有没有办法仍然访问这些值?

  3. 如果它们仍在消耗内存空间,是否可以释放该空间?

variables types rust

6
推荐指数
1
解决办法
1023
查看次数

返回后是否可以编写语句?

return声明的最后一条语句里面main还是有可能写的语句返回后?

#include <iostream>

using namespace std;

int main() {

    cout << "Hello" << endl;

    return 0;

    cout << "Bye" << endl;
}
Run Code Online (Sandbox Code Playgroud)

该程序编译但只显示“Hello”。

c++ program-entry-point function

3
推荐指数
1
解决办法
852
查看次数

标签 统计

c++ ×1

function ×1

program-entry-point ×1

rust ×1

types ×1

variables ×1