Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoklavat committed Feb 2, 2021
1 parent 8083d56 commit 665676b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions 52-UserDefinedLiteral.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//52-UserDefinedLiteral

#include <iostream>

class A{
public:
A(int x): a{x}{}
int a;
};

A operator ""_S(long double x){
return A{x*x}; //square.
}

int main(){
A a{12.0_S};
std::cout << a.a << std::endl;
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@
- 48-RuleOfFive
- 49-ExplicitDestructor
- 50-PolymorphicException
- 51-OperatorOverloading
- 51-OperatorOverloading
- 52-UserDefinedLiteral

0 comments on commit 665676b

Please sign in to comment.