How to cout first value of dynamic variable ?

I coded some classes and overloaded << operator. When i cout a dynamic variable of my classes, it shows me its address.

I am looking for an alternative that i can use instead of
 
 cout << DynamicVariable[0] << endl;


1
2
3
4
5
6
7
 
//Here is my code that i am working

 Drink* test = new Drink("Cola",5.5);

 cout << test[0] << endl; /*this gives me the result that i want but i wanted to ask if there is
                                          another alternative i can use to do the same thing*/
Last edited on
std::cout << *test << '\n';
Treating a pointer to a single instance as an array is a bad idea. There are subtle differences between an array and a pointer.

Topic archived. No new replies allowed.