Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Conversion from Class Type to Basic Type `*/
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- class C{
- int m;
- public:
- C(int);
- ~C();
- operator int();
- };
- inline C::C(int m){
- C::m = m;
- }
- inline C::~C(){
- cout << "Destructor Called" << endl;
- }
- inline C::operator int(){
- return m;
- }
- int main() {
- C obj(6);
- int a = obj;
- cout << "a = " << a << endl;
- cin.get();
- return 0;
- }
Add Comment
Please, Sign In to add comment