Add 'ex1.cpp'

main
sigonasr2 2 years ago
parent f4ceb81c4f
commit 686379839e
  1. 20
      ex1.cpp

@ -0,0 +1,20 @@
#include <vector>
#include <iostream>
class MyClass{
public:
int val=0;
MyClass(int val)
:val(val){};
};
int main() {
std::vector<MyClass> myitems;
for (int i=0;i<20;i++) {
myitems.push_back({i});
}
for (int i=0;i<myitems.size();i++) {
(&myitems[i])->val++;
std::cout<<myitems[i].val<<"\n";
}
}
Loading…
Cancel
Save