Created
May 23, 2022 01:33
-
-
Save rahulbhadani/ac89733855dacfddb249fc90b189019f to your computer and use it in GitHub Desktop.
Return Value Optimization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <functional> | |
#include <iostream> | |
#include <optional> | |
class Test { | |
public: | |
Test() | |
{ | |
std::cout<<"Default Constructor\n"; | |
} | |
Test(const Test&) | |
{ | |
std::cout << "A copy constructor was called\n"; | |
} | |
}; | |
Test func() | |
{ | |
return Test(); | |
} | |
int main() { | |
std::cout << "Hello World!\n"; | |
Test obj = func(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment