I created a struct named products that contains multiple data types:
struct products{
int ID;
string Name;
double Price;
int Quantity;
};
Then in the main function, I created an array named details which utilizes the struct products:
int main(){
struct products details[5];
Then I gave each array element data.
details[0] = {1, "Apple Juice", 12, 240};
details[1] = {2,"Bread", 10, 100};
details[2] = {3, "Chocolate", 5, 500};
details[3] = {4, "Dates", 50, 150};
details[4] = {5, "Eggs", 30, 360};
finally, I tried to print the values of the element at index 2:
cout<<details[2];
it gave me this error:
"Invalid operands to binary expression ('std::ostream' (aka 'basic_ostream') and 'struct products')"
Here is a picture of the whole code

productsthat is not in an arrayoperator<<yourself.cout<<details[2].IDand similar constructs for the other things you want to printproducts. The array is also completely irrelevant; you would see the same error withproducts p; std::cout << p;