How can I initialize an array whose type is a struct?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a short code to print the month and days in a month. I declared a struct including month and days. but it does not work.

Please help me.

#include<iostream>
#include<vector>
using namespace std;

struct year{
char* month;
int day;
};

int main(){

vector<year>arr(("Jan",31),("Feb",28));
vector<year>::iterator iter;
for(iter=arr.begin(); iter!=arr.end(); iter++)
cout<<iter->month<<" "<<iter->days<<endl;
return 0;
}

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux