Expand|Select|Wrap|Line Numbers
- #include <c:\djgpp\include\stdio.h>
- #include <c:\djgpp\include\stdlib.h>
- #include <c:\djgpp\include\string.h>
- #include <vector>
- using namespace std;
- class PhrasePool{
- public:
- vector<int> num;
- PhrasePool(){
- num[0]=1;
- }
- };
- int main(){
- PhrasePool TempPool,TempPool2;
- for(int x=1;x<10;x++){
- TempPool.num[x]=x;
- }
- for(int x=1;x<10;x++){
- TempPool2.num[x]=10;
- }
- for(int x=0;x<10;x++){
- printf("%d",TempPool.num[x]);
- }
- return 0;
- }
1101010101010101010
When I expect to get:
1123456789
Essentially I expect to have an individual copy of a vector of integers called num in each of TempPool and TempPool2. However it appears that I have just one shared vector of integers much as if I had declared the vector static.
Any clues as to why this is happening and/or how to fix the code so that it behaves as expected?
Thanks in advance to anyone kind enough to help.