📜  我们可以在C和C++的表达式左侧使用函数吗?

📅  最后修改于: 2021-05-25 19:04:08             🧑  作者: Mango

在C语言中,可能无法在表达式的左侧使用函数名,但在C++语言中是可能的。

#include
  
using namespace std;
  
/* such a function will not be safe if x is non static variable of it */
int &fun()
{
   static int x; 
   return x;
}    
  
int main()
{
   fun() = 10;
  
   /* this line prints 10 on screen */
   printf(" %d ", fun());
  
   getchar();
   return 0;
}
要从最佳影片策划和实践问题去学习,检查了C++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程”