2016-02-06T06:02:24-05:00
Define structure for the following:-
(a)Roll number,Name,Marks.
(b)Day,Month,Year.
1
2016-02-11T00:00:47-0500
#include<string> #include<vector> #include<cinttypes> #include<iostream> using namespace std; typedef int marks_t; /* a) */ struct person { string roll_number; struct name_t { string first,second; string full() const { return first+(first.empty()?"":" ")+second; } } name; vector<marks_t> marks; }; ostream& operator<<(ostream& o,const person&j) { o << "Roll №: " << j.roll_number << endl << "Name: " << j.name.full() << endl; o << "Marks: "; for(size_t i=0;i<j.marks.size();++i) o << j.marks[i] << " "; o << endl; return o; } /* b) */ struct date { uint8_t day; uint8_t month; uint16_t year; }; int main() { person p; p.roll_number = "A1S2D3F4"; p.name.first = "GF"; p.name.second = "Expert"; marks_t m[]{1,2,3,4,5}; p.marks = vector<marks_t>(m,m+sizeof(m)/sizeof(marks_t)); cout << p; return 0; }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments