Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Vector of pointer of P...
//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 p: vp) cout << p.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 pp: vpp) cout << pp->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
template specialization inheritance solution
selection sort
DESim Example Starter Code
function returning a function demo
Store Information in Structure and Display it
Fun with Pointers #2
radixSort
First test
Throttle Example (Send two requests every two seconds)
auto Keyword Example