Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
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
Please
log in
to post a comment.
insertion sort
ArrayList Example Starter Code 2
wasm test for node
Simple Generic Data Type Example
Throttle Example (Send two requests every two seconds)
wellformed number
Variable declarations in while loop conditions are also C++-only.
Exploring stringstreams
Store Information in Structure and Display it
cv5_class
Please log in to post a comment.