Skip to content

Instantly share code, notes, and snippets.

@rscarvalho
Created May 13, 2010 22:26
Show Gist options
  • Save rscarvalho/400561 to your computer and use it in GitHub Desktop.
Save rscarvalho/400561 to your computer and use it in GitHub Desktop.
#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