How would you make a class that has a vector of integers as its' private data member. And exactly how would you implement certain member functions in that class to obtain the largest, smallest, and average of that vector of integers? I'm not quite sure how to write the header or the implementation files for this class?
Should have paid attention in lectures friendo.
choose a new major/degree OP
If you can't do that - there's no hope, your parents won't mind
It's like a fireman asking what is water
Dude this stuff is literally first semester CS. There's nothing about std::vector that makes it not able to be a private member.
>>61191370
make a class that holds a vector of integers as a private data member
after that implement methods to find the largest, smallest and the average member
there you go, its really simple
>>61191597
I guess I should rephrase my question.
I'm suppose to make a vector a private member (ok, so I know how to do that)
but the specifications asks for me to make function setIntValue, but doesn't tell me what it is suppose to do.
A vector is just an ordered collection of elements like a deque and a list. But, am I to just add an element in setIntValue, or what?
>>61191597
Nothing to hide?
or set the value of just one of it's element?
>>61191370
Just make a private vector and implement functions to do what you ask. What even is your question?
>>61191633
ask the person who made the specifications? are you dumb?
>>61191633
Never make a function called setIntValue
-"Value" is unnecesary for POD type like int
-set "int" value? Which int? If the class has two ints - foo and bar which is it setting? How do you name other function setIntTwo? Use setFoo and setBar.
setIntValue implies a singular int, not a vector of them
>>61191633
>setIntValue()
10/10 function naming
your lecturer sure is a pro
>>61191370
This thread smells of curry.
>>61191370
These are the only acceptable implementations.
>largest
std::max_element(v.begin(), v.end())
>smallest
std::min_element(v.begin(), v.end())
>average of that vector of integers
std::accumulate(v.begin(), v.end(), 0) / v.size()
>>61191807
Are they in <algorithm>?
>>61191807
Congrats on doing OP's homework for him, now he's learned nothing except how to continue leech off of others.
>>61191837
Less competition for me. =)
I'm surprised that no-one has pointed out that OP is an underage elementary school student.
>>61191370
>I'm not quite sure how to write the header or the implementation files for this class?
Dude. Google before you start a whole fucking thread on /g/. Learn to think critically. Trust me, it's great