For starter this is my first language and I am taking a class in C++. We have a homework assignment that asks use to input strings and draw a box and places the strings in the center. I would like to use an accumulator but the book does not provide anexample of it and this week I am not able to make it to my professor's office hours.
but i still need a little clarity.
My question is what is the proper way to use it and what is the correct syntax, meaning just like getline would look like this getline(cin, string), how would an accumulator look like? Or what parts does it consist of?
I apologize if the question is too vague or difficult to read but I did not know how else to ask it. Any help is greatly appreciated. Thanks in advance.
I'm not sure in what way you're trying to use accumulate for your problem.
As shown in the example on the reference, you can use it to e.g. sum a range of numbers in an array.
You could also use it to concatenate some strings:
accumulate takes an iterator range like many other algorithms in the standard library.
I'm not sure if you've covered iterators yet, but they're essentially objects that you can dereference and advance (meaning calling operator++ on it) and are used to iterate over a range of values. So regular pointers also count as iterators.
I am trying have the user input as many string as they would like, and have the accumulate store them so I can check which string is the longest to help determine the size of the box I need. And no we have not covered iterators yet.
Just to know could you use a accumulator to store the strings and then use find to find \n to calculate how many characters are in each string entered.
You could, but it would be a clumsy way of doing it, since you don't need to concatenate all those strings to store them and figure out which one is the longest.
I figure it would be a clumsy way, but since I am new to this I only have limited amount of information to work with, and since we are beginning to work with accumulator I figure we need to use them.