Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
vector flavors....
//clang 3.8.0 #include <iostream> #include <vector> using namespace std; class P { public: P(int p):i(p) { } int getElem() {return i;} private: int i; }; int main() { cout << "Hello, world!\n"; vector<int> vi; vi.push_back(10); vi.push_back(20); vi.push_back(30); for(auto elem: vi) cout << elem << endl; cout << endl; vector<P> vp; vp.push_back(P(100)); vp.push_back(P(200)); vp.push_back(P(300)); for(auto elem: vp) cout << elem.getElem() << endl; cout << endl; vector<P*> vpp; vpp.push_back(new P(1000)); vpp.push_back(new P(2000)); vpp.push_back(new P(3000)); for(auto elem: vpp) cout << elem->getElem() << endl; cout << endl; vector<P*>::iterator vectorBeginIter = vpp.begin(); vector<P*>::iterator vectorEndIter = vpp.end(); while(vectorBeginIter != vectorEndIter) { cout << (*vectorBeginIter)->getElem() << endl; vectorBeginIter++; } cout << endl; }
run
|
edit
|
history
|
help
0
chakib
CS1428 SI Tuesday
appliWall
Compute Power Manually
What's the problem with this?
pointer to complete array does not convert implicitly to pointer to array of unknown bound
test
Member inheritance
Ordered Graphs
Vector examples....