Making my own toString() method on c++ struct

I’m used to oveerriding the Java toString() method on my own objects in classes, but I’m not sure where I’m going wrong with the following code: I’m only beginning to learn c++ so any advice would be appreciated

How do sizeof(arr) / sizeof(arr[0]) work?

If you have an array then sizeof(array) returns the number of bytes the array occupies. Since each element can take more than 1 byte of space, you have to divide the result with the size of one element (sizeof(array[0])). This gives you number of elements in the array. Example: LIVE EXAMPLE Note that if you … Read more

C++ equivalent of Java’s toString?

In C++ you can overload operator<< for ostream and your custom class: This way you can output instances of your class on streams: In case your operator<< wants to print out internals of class A and really needs access to its private and protected members you could also declare it as a friend function:

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)