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";
}
book.resize(book.size()++);
you can't call++
,book.size()
is not "L-value", it is not a reference. should bebook.resize(book.size()+ 1);
also insdead ofwhile ...
you can callbook.resize(n);
but he view problem on vector book(5);
vector book(5); he view: expected constructor, destructor, or type conversion before '<' token
may be problem on struct? :(
I think you forgot to include vector.
I'm not understand... What does it mean?
Ooo, I'm Understand! That need (#include).....