Beginner question here, I need to assign the same value to every element of an array, and have the computer output that value to the console. After I accomplish this, I will be adding another function that will randomly assign a different value to each element of the array, but I haven't got there yet. This program outputs the location of the element, instead of its value.
How can I change the assignment statement in the Constructor's definition, or change the output statement in the print function to output the value of the element.Code:#include <iostream> using namespace std; class List{ private: int myarray [99]; public: List(); void print(); }; int main(){ List storesamevalue; storesamevalue.print(); return 0; } List::List(){ int myarray [99]=99; } void List::print(){ cout<<myarray[1]; }
Thanks.



LinkBack URL
About LinkBacks


