Created
May 12, 2009 05:07
-
-
Save jcsalterego/110319 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| // prototype | |
| vector<int> & buy(); | |
| int main () | |
| { | |
| vector<int> j; | |
| j = buy(); | |
| for (int i = 0; i < j.size(); i++) { | |
| cout << "j[" << i << "] = " << j[i] << endl; | |
| } | |
| // should print out: | |
| // j[0] = 1 | |
| // j[1] = 2 | |
| // j[2] = 3 | |
| return 0; | |
| } | |
| vector<int> & buy() | |
| { | |
| vector<int> *foobar = new vector<int>; | |
| foobar->push_back(1); | |
| foobar->push_back(2); | |
| foobar->push_back(3); | |
| return *foobar; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment