Created
May 13, 2010 22:26
-
-
Save rscarvalho/400561 to your computer and use it in GitHub Desktop.
This file contains 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<iostream> | |
#include<string> | |
using namespace std; | |
class Book | |
{ | |
public: | |
Book(string a, double o) : author(a), other(o) {} | |
string author; | |
double other; | |
string getHello(){ | |
return author; | |
} | |
string getHello(int i){ | |
return author + " -- "; | |
} | |
}; | |
string Book::* AuthorPtr = &Book::author; | |
string (Book::* HelloPtr)(int) = &Book::getHello; | |
int main(int argc, char* argv[]) | |
{ | |
Book *b = new Book("Hello", 2.0); | |
cout << "Author: " << (b->author) << endl; | |
cout << AuthorPtr << endl; | |
cout << "Author catched: " << (b->*AuthorPtr) << endl; | |
cout << "Hello: " << (b->*HelloPtr)(2) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment