[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Hey, /wsr/. I noticed in the sticky that this board helps with
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /wsr/ - Worksafe Requests

Thread replies: 9
Thread images: 3
File: 6.jpg (47 KB, 602x310) Image search: [Google]
6.jpg
47 KB, 602x310
Hey, /wsr/. I noticed in the sticky that this board helps with homework.

I have 3 c++ programs that are pretty much finished i just need some help fixing some things.

Thanks
>>
OK.

Done.
>>
so you will help me?
>>
just post your problem feggit
>>
no match for 'operator=' (operand types are 'std::vector<std::basic_string<char> >' and 'std::string {aka std::basic_string<char>}')
>>
File: Capture.png (21 KB, 919x841) Image search: [Google]
Capture.png
21 KB, 919x841
>>
File: Capture1.png (20 KB, 858x789) Image search: [Google]
Capture1.png
20 KB, 858x789
>>
It's been a while since I've done C++ but of course that's a type error. See if you can fix it with typecasting. Looks like your vector isn't actually of type string? It's a finicky language, if you google your error I'm sure stackoverflow has already answered your problem.
>>
>>81035
>vector<some_type> variable_name[WHAT_THE_FUCK_ARE_YOU_DOING_HERE_NIGGER];

There's your problem, you're creating an ARRAY OF vector<some_type> and not vector of that size. If you want to pre-allocate the size of the vector use "variable_name(size, starting_value)" or just "variable_name(size)".

And why use vectors in the first place? A dumb array (or std::array) is good enough:

struct student{
string name;
double score;
};

student students[5];
double totalScores=0;

for(kid : students){
cout<<"Enter the name of the student: ";
cin >> kid.name;
cout<<"Enter "<<kid.name<<"'s test score: ";
cin>>kid.score;
totalScores+=kid.score;
}
cout<<"The average test score is "<<totalScore/5<<endl;
Thread replies: 9
Thread images: 3

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.