
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Pretty Function, Function, and Func in C/C++
Here we will see what are the differences between __FUNCTION__, __func__ and the __PRETTY_FUNCTION__ in C++.
Basically the __FUNCTION__ and __func__ are same. Some old versions of C and C++ supports __func__. This macro is used to get the name of the current function. The _PRETTY_FUNCTION__ is used to return the detail about the function. Using this we can get which function is used, and in which class it is belonging, etc.
Example
#include<iostream> using namespace std; class MyClass{ public: void Class_Function(){ cout << "The result of __PRETTY_FUNCTION__: " << __PRETTY_FUNCTION__ << endl; } }; void TestFunction(){ cout << "Output of __func__ is: " << __func__ << endl; } main() { cout << "Output of __FUNCTION__ is: " << __FUNCTION__ << endl; TestFunction(); MyClass myObj; myObj.Class_Function(); }
Output
Output of __FUNCTION__ is: main Output of __func__ is: TestFunction The result of __PRETTY_FUNCTION__: void MyClass::Class_Function()
Advertisements