Add 'ex1.cpp'
This commit is contained in:
parent
f4ceb81c4f
commit
686379839e
20
ex1.cpp
Normal file
20
ex1.cpp
Normal file
@ -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…
x
Reference in New Issue
Block a user