Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using std::cout;
- using std::string;
- class Boy {
- public:
- Boy() {
- cout << "Boy constructor one\n";
- }
- Boy(int n) {
- cout << "Boy constructor two, n = " << n << "\n";
- }
- void hello(string name) {
- cout << name << " say hello method.\n";
- }
- };
- int main(int argc, char *argv[]) {
- system("color f0");
- Boy boy1;
- boy1.hello("boy1");
- cout << "\n";
- Boy boy2(5);
- boy2.hello("boy2");
- cout << "\n";
- Boy *boy3 = new Boy;
- boy3->hello("boy3");
- cout << "\n";
- Boy *boy4 = new Boy();
- boy4->hello("boy4");
- cout << "\n";
- Boy *boy5 = new Boy(16);
- boy5->hello("boy5");
- cout << "\n";
- Boy *boy6 = NULL;
- boy6 = new Boy(20);
- boy6->hello("boy6");
- cout << "\n";
- cout << "\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement