Why's my code throwing an error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
13th Feb 2022, 9:57 AM
Rishi
Rishi - avatar
9 Answers
+ 5
Remove & in all statements of vector definition, and declarations: use only std::vector<int> calc(int len,int width);
13th Feb 2022, 10:09 AM
Jayakrishna 🇮🇳
+ 5
Jayakrishna🇮🇳 but why's the & producing the error?
13th Feb 2022, 1:41 PM
Rishi
Rishi - avatar
+ 5
Solomoni Railoa no, it's pass by value by default. Yeah I'll take a look at that👍
13th Feb 2022, 1:56 PM
Rishi
Rishi - avatar
+ 5
Jayakrishna🇮🇳 Solomoni Railoa Ash I've found the error! The error was because of returning a reference to a local variable from a function. I've fixed it as below and works good https://code.sololearn.com/ctyTNeGC4hMx/?ref=app
14th Feb 2022, 2:24 AM
Rishi
Rishi - avatar
+ 4
Pradeep Pogunulla only post related to the question in the answer section
14th Feb 2022, 8:41 AM
Rishi
Rishi - avatar
15th Feb 2022, 10:38 AM
Rishi
Rishi - avatar
0
https://discord.gg/kre5HQa7ea computer science stuff
14th Feb 2022, 7:31 AM
Pradeep Pogunulla
Pradeep Pogunulla - avatar
- 3
Zor
14th Feb 2022, 10:55 AM
Мухарамой Урайимова
- 3
بده
15th Feb 2022, 9:21 AM
رادمهر مظفری