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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Can we use % operator on floating point numbers?
- How can we use Comma operator in place of curly braces?
- ios manipulators left() function in C++
- Why strcpy and strncpy are not safe to use?
- Features and Use of Pointers in C/C++
- Left Shift and Right Shift Operators in C/C++
- Increment (Decrement) operators require L-value Expression
- Lambda expression in C++
- std::regex_match, std::regex_replace() | Regex (Regular Expression) In C++
- Do not use sizeof for array parameters
- When do we use Initializer List in C++?
- Use of explicit keyword in C++
- How to use getline() in C++ when there are blank lines in input?
- Different ways to use Const with Reference to a Pointer in C++
- How to use make utility to build C projects?`
- How to use unordered_map efficiently in C++
- Left-Right traversal of all the levels of Binary tree
- Can we call an undeclared function in C++?
- Can we access private data members of a class without using a member or a friend function?
- What are the operators that can be and cannot be overloaded in C++?

