Created
March 11, 2015 12:04
-
-
Save anonymous/56892ac096ea8bcb896c to your computer and use it in GitHub Desktop.
Decorator
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
// ConsoleApplication2.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
#include <string> | |
#include <iostream> | |
using std::string; | |
using std::cout; | |
using std::endl; | |
using std::cin; | |
class User { | |
private: | |
string name; | |
string pass; | |
public: | |
User *create(string name, string pass){ | |
this->name = name; | |
this->pass = pass; | |
cout<<name<<endl; | |
cout<<pass<<endl; | |
return this; | |
} | |
}; | |
class GoogleAnalytics : public User { | |
private: | |
User *user; | |
public: | |
GoogleAnalytics(User *user){ | |
this->user = user; | |
this->create("jackie", "chan"); | |
} | |
User * create(string username, string password){ | |
cout<<"sending data to GA server\t"<<username<<endl; | |
return user->create(username, password); | |
} | |
}; | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
User user; | |
User *userWithParams = user.create("maksadbek", "password"); | |
User decoratedUser = GoogleAnalytics(new User); | |
cout<<decoratedUser.name<<endl; | |
string input; | |
cin>>input; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment