const_pointer vector<X,A>::data() const;
#include <vector>
pointer vector<X,A>::data();
#include <iostream> #include <vector> int main() { using namespace std; // Create a vector instance vector<char> qV; qV.push_back('X'); qV.push_back('o'); qV.push_back('a'); qV.push_back('X'); qV.push_back('.'); qV.push_back('n'); qV.push_back('e'); qV.push_back('t'); // The data() function returns a pointer to the first entry. // We can use either a pointer or const_pointer. vector<char>::pointer qConstPtr= qV.data(); vector<char>::const_pointer qPtr = qV.data(); cout << "const pointer points to: " << *qConstPtr << endl; cout << "pointer points to: " << *qPtr << endl; // Keep the window open cin.get(); return 0; }
© 20072025 XoaX.net LLC. All rights reserved.