Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Strange behaviour

Reply
Thread Tools

Strange behaviour

 
 
Ioannis Vranos
Guest
Posts: n/a
 
      10-02-2008
The code:

#include <iostream>
#include <ctime>
#include <vector>
#include <cstddef>


struct SomeClass
{
typedef std::vector<int> TypeVector;

TypeVector vec;

enum { VectorSize= 10 };

public:

SomeClass();
};



SomeClass::SomeClass():vec(VectorSize)
{
using namespace std;

srand(time(0));

for(TypeVector::size_type i= 0; i< vec.size(); ++i)
{
vec[i]= rand();

cout<<vec[i]<<" ";
}

cout<<"\n\n";
}



int main()
{
using namespace std;

const size_t SIZE=10;

typedef vector<SomeClass> Vector;

cout<< "\nCreating vector with "<< SIZE<< " SomeClass objects..."<<
endl;
Vector vec(SIZE);

}


in my system produces:


john@john-desktop:~/Projects/Other/anjuta1/src$ ./foobar_cpp

Creating vector with 10 SomeClass objects...
721719660 2021996343 352419231 1918327853 2096709369 504143813
1554377841 1136725920 697167326 165934869

john@john-desktop:~/Projects/Other/anjuta1/src$




(10 values) instead of 100 values. Is it a compiler defect, or am I
missing something?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
debugger behaviour different to execution behaviour Andy Chambers Java 1 05-14-2007 09:51 AM
a strange behaviour of FF Maurice Firefox 2 03-11-2005 11:53 PM
Strange mouse behaviour with flash in Mozilla 1.3.7 hpoppe Firefox 0 11-07-2004 12:16 PM
Strange taskbar behaviour (notification area) Falcon Wireless Networking 0 08-17-2004 09:03 AM
[mozilla1.6] strange behaviour with newsgroup joost68 Firefox 5 04-03-2004 03:48 AM



Advertisments