ThE_aLpHaBeAt's blog

By ThE_aLpHaBeAt, 11 years ago, In English

This is my code... they view error on vector book(5), Why?

#include<iostream>
using namespace std;
struct letter
{
  string name;
  int age;       
};
vector<letter> book (5);

int main()
{
 int n,i;
 cin>>n;
 while (book.size()<n-1) 
 {
  book.resize(book.size()++);      
 }  
 for (i=0;i<n;i++)
 {
  cin>>book[i].name;
  cin>>book[i].age;    
 }
 cout<<"Information Added!!!\n";
}

Full text and comments »

  • Vote: I like it
  • -14
  • Vote: I do not like it