Skip to content

Instantly share code, notes, and snippets.

@henrybear327
Created March 28, 2017 06:23
Show Gist options
  • Save henrybear327/fa461b00bca3f2ba75f73e7a8ea1f4eb to your computer and use it in GitHub Desktop.
Save henrybear327/fa461b00bca3f2ba75f73e7a8ea1f4eb to your computer and use it in GitHub Desktop.
class.cpp
#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