+ 1

error in structure printing

structure required on left side l or .* what does it means

8th Mar 2017, 12:18 PM
Samarth Sundaram
Samarth Sundaram - avatar
1 Answer
+ 2
if you make a struct mstruct. then make objects of mstruct type, obj1, obj2. you cannot simply say cout << obj1; you need to do 1 of 2 things. create a print function for mstruct and call it obj1.print(); or overload the << operator to print it out. ostream operator << (ostream & os, const mstruct & obj){ os << obj.val; return os; } cout << obj1; hope this helps
10th Mar 2017, 5:12 AM
Michael Szczepanski
Michael Szczepanski - avatar