我在学习指针和引用,但是我很难理解概念。我需要在主函数中声明一个变量,然后通过用户输入的函数初始化它,而不返回任何内容。我试过了:初始化变量透过函数
#include <iostream>
using namespace std;
void input(int &num){
cout << "Enter A Number" << endl;
cin >> static_cast<int>(num);
}
int main(){
int x;
input(x);
cout << "The Number You Entered Was " << x << "!" << endl;
return 0;
}
然后呢? – Vijay