Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyClass1 {
- public:
- MyClass1() {
- printf( "constructorn" );
- }
- ~MyClass1() {
- printf( "destructorn" );
- }
- int var1;
- std::string str;
- };
- std::vector< MyClass1 > testArr;
- MyClass1 gr1;
- gr1.var1 = 111;
- testArr.push_back( gr1 );
- gr1.var1 = 122;
- testArr.push_back( gr1 );
- printf( "testArr.at( 1 ).var1 = %in", testArr.at( 1 ).var1 );
- #include <iostream>
- #include <cstdio>
- #include <vector>
- using namespace std;
- class MyClass1 {
- public:
- MyClass1() {
- printf( "constructorn" );
- }
- ~MyClass1() {
- printf( "destructorn" );
- }
- int var1;
- string str;
- };
- int main()
- {
- vector< MyClass1 > testArr;
- MyClass1 gr1;
- gr1.var1 = 111;
- testArr.push_back( gr1 );
- gr1.var1 = 122;
- testArr.push_back( gr1 );
- printf( "testArr.at( 1 ).var1 = %in", testArr.at( 1 ).var1 );
- return 0;
- }
- constructor
- destructor
- testArr.at( 1 ).var1 = 122
- destructor
- destructor
- destructor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement