Can we use function on left side of an expression in C and C++?
In C, it might not be possible to have function names on left side of an expression, but it’s possible in C++.
#include<iostream> 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; } |
chevron_right
filter_none
Please write comments if you find anything incorrect or want to share more information about the topic discussed above.
Recommended Posts:
- ios manipulators left() function in C++
- Lambda expression in C++
- Increment (Decrement) operators require L-value Expression
- std::regex_match, std::regex_replace() | Regex (Regular Expression) In C++
- Left-Right traversal of all the levels of N-ary tree
- Left Shift and Right Shift Operators in C/C++
- Function Overloading vs Function Overriding in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- Difference between Virtual function and Pure virtual function in C++
- log() function in C++
- arc function in C
- exp() function C++
- fma() function in C++
- div() function in C++
- vswprintf() function in C/C++

