可能具有指针函数的模糊赋值

Vague Assignment with possible pointer function

本文关键字:模糊 赋值 函数 指针      更新时间:2023-10-16

这是一个类赋值,我必须在没有太多细节的情况下弄清楚程序中发生了什么,然后让它发挥作用。看起来函数可能打算在原型中使用指针类型int,但在定义中没有*。我可以根据需要自由更改代码,但我应该保留函数。有什么建议吗?

// Question4
//
// This question has no instructions, simply make it work properly.
// (Ask for a number and print it out.) Keep the function.
//
#include <iostream>
void MyFunc( int * ) ;
int main()
{
int i = 0;
cout << “Enter an integer: " << endl;
cout << "The value entered is: " << MyFunc(i) << endl;
}
void MyFunc( int x )
{
cin >> x ;
cout << "nnn";
return x;
}

任一:

  • 使函数返回int
  • 让函数返回像int一样打印的东西(有点棘手,用于测试你的老师)
  • 将参数设为int引用并返回该引用