Coding Global Background
Coding Global

Adding an int value to a vector using recursion

Archiviert 3 years ago
1 Nachrichten
1 Mitglieder
3 years ago
In Discord öffnen
S
<3
Verified

I have a 1-dimensional vector function. Tried inputting elements using recursion. ```c++ #include<vector> #include<iostream> using namespace std; int input(vector <int> &arr); int input(vector <int>& arr) { int n{0}; char condition{'Y'}; cout<<"Do you wan to add an element to the dataset?(Y/N): " << endl; cin >> condition; if(condition== 'Y' || condition=='y') { cout<<"Enter the element you want to add: " ; int temp{}; cin>>temp; arr.push_back(temp); return input; } } ``` Errors i get: return value does not match function type. tysm for reading this <3 idfk what i'm doing :(*

Antworten (1)