Created
March 28, 2017 06:23
-
-
Save henrybear327/fa461b00bca3f2ba75f73e7a8ea1f4eb to your computer and use it in GitHub Desktop.
class.cpp
This file contains hidden or 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> | |
using namespace std; | |
class Test | |
{ | |
public: | |
Test(); | |
Test(int num); | |
private: | |
int number; | |
}; | |
Test::Test() | |
{ | |
printf("Default constructor\n"); | |
} | |
Test::Test(int num) | |
{ | |
number = num; | |
printf("number = %d\n", number); | |
} | |
int main() | |
{ | |
Test object1, object2, object3, object4; | |
printf("%p %p %p %p\n", &object1, &object2, &object3, &object4); | |
object1 = Test(1); | |
object2 = Test(2); | |
object3 = Test(3); | |
object4 = Test(4); | |
printf("%p %p %p %p\n", &object1, &object2, &object3, &object4); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment