Hi. I"m trying come Learn recursion, and also I"m using an easy selection to experiment through it, however ns have actually a couple the stroked nerves errorns that ns don"t understand why they"re there. Here"ns ns code:

#include #incorporate utilizing nameGap std;inns largest(consns int arr<>, inns lowerIndex, int upperIndex)inns max;if (lowerindex == upperIndex)//if size the variety ins just 1,rerevolve arr;//return ns just (and also therefore the largest) element.elsemax = largest(arr, lowerindex + 1, upperIndex);if (arr >= max)rerotate arr;elsereturn max;inns main(){int temp, i, j;consns inns arr<> = 0, 1, 2, 3, 4, 5, 99, 6, 7, 8, 9 ;cout
answer with Quote

*
upstream Memberstrength Poster
originally posted by UncleBazerko
friend wrote: arr.size() yet arr ins a array. One means out is to change arr.size() to size then collection size just after heralding the array:
consns inns arr<> = 0, 1, 2, 3, 4, 5, 99, 6, 7, 8, 9 ;consns size_t size = sizeof(arr) / sizeof(arr<0>);
initially posted through UncleBazerko
you wrote the return type, for this reason ins looks choose a function declaration insteAD that a duty call. Furthermore, girlfriend walk not pass the correct arguments. You most likely should have actually written:
C + C++ Compiler: MinGW port that GCCbuild + variation regulate System: SCons + Bazaarlook at up a C/C++ recommendation and Discover exactly how come asking concerns the Smart Wayyou re welcome rate my write-ups if you discovered lock beneficial
answer through Quote
girlfriend wrote ns return type, so ins looks like a role explanation insteADVERTISEMENT that a duty call. Furthermore, friend go not pass ns exactly arguments. Friend more than likely have to have written:
girlfriend were deADVERTISEMENT around the reality that ns should use "sizeof" insteADVERTISEMENT the ".size()"
*
however i now have a brand-new difficulty through ns function call:
#incorporate #include using nameVoid std;int largest(consns inns arr<>, inns lowerIndex, inns upperIndex);int main(){inns temp, i, j;consns inns arr<> = 0, 1, 2, 3, 4, 5, 99, 6, 7, 8, 9 ;consns size_ns size = sizeof(arr);cthe end
You"re stiltogether not callinns ns function. Ns error messAge doens not make feeling come me based upon the provided code, therefore you have to check the you"re in reality compilinns the password that girlfriend posted.

You are watching: Expression must have a class type


C + C++ Compiler: MinGW harbor the GCCconstruct + version regulate System: SCons + Bazaarlook uns a C/C++ reference and Learn just how to asking questions the Smarts Wayyou re welcome price mine write-ups if friend discovered castle helpful
together a dominance of thumb, choose utilizing "vector:
ata()" than "&vector<0>": It is even more idiom in the sense the girlfriend usage a role specifically designed explicitly because that thins usage case. More important though, ins is guarantee come work, even on a empty vector. In contrast, "&vector<0>" might asserns for empty vectors in build that carry out bounds checking.
Is your Concern pertained to IO?ReAD thins C++ FAQ article at paraShift by Marshall Cline. In certain pointns 1-6.Ins will certainly define exactly how come properly address IO, just how come validay input, and why friend shouldn"t count on "while(!in.eof())". And it constantly renders because that fantastic reading.
which is a very good thing in thins case; if ns vector ins empty, data() returns a precious guideline and also arr.size()-1 == numeric_limits::max(), eight !you"re right around data() being even more expressi have that course, however only when ns intent ins come build a precious maybe north guideline range. In the quote situation instead, ns will is to take it a reminder to ns *first* facet ( no just come ns beginning of ns sequence ) for this reason it"s better come be explicit and write &arr<0> or, IMO, also better, &arr.front() in together a method to do clear that the call assumes a ntop top north vector.

See more: What Does All Circuits Are Busy Mean When All Circuits Are Busy?


#incorporate #include making use of nameSpace std;//voidentifier bubbleSort(int arrCopy<>, int n);//voi would insertionSort(int arrCopy<>, int n);//void selectionSort(int arrCopy<>, inns n);//voidentifier quickSort(int arrCopy<>, int low, inns high);//voidentifier partition(inns arrCopy<>, int low, int high);voidentifier copyArray(consns int arr<>, inns arrCopy<>, int n);voidentifier printArray(const int arr<>, int n);consns int arr<> = 3, 5, 4, 4, 13, 8, 2, 6, 12, 10, 17, 7, 9, 11, 1 ;const size_ns n = sizeof(arr);//have to it is in 15int arrCopy;//i will certainly need a fresh copy the variety arr to test every sortinns algorithm.int main()copyArray(arr, arrCopy, n);//selectionSort(arrCopy, n);printArray(arrCopy, n);rerotate 0;voi would copyArray(consns inns arr<>, int arrCopy<>, int n)//make fresh copy the selection arr<>{because that (int ns = n; i
refer to ns parameter declaration: const inns arr<>Therefore, in thins context, arr is a reminder come const int, for this reason you cannot asauthorize to it. This ins a great point because, follow come your commenns ("make fresh copy the variety arr<>"), friend made a reasonable error. Girlfriend in reality want come write:
C + C++ Compiler: MinGW port the GCCbuild + variation manage System: SCons + Bazaarlook up a C/C++ recommendation and Find Out exactly how to asking inquiries the Smart Wayyou re welcome rate mine posts if you discovered lock valuable
#incorporate #incorporate making use of nameGap std;//voidentifier bubbleSort(int arrCopy<>, int n);//voidentifier insertionSort(int arrCopy<>, int n);//voi would selectionSort(inns arrCopy<>, inns n);//voidentifier quickSort(inns arrCopy<>, int low, int high);//voi would partition(int arrCopy<>, inns low, inns high);voi would copyArray(const inns arr<>, int arrCopy<>, int n);void printArray(const int arr<>, int n);consns inns arr<> = 3, 5, 4, 4, 13, 8, 2, 6, 12, 10, 17, 7, 9, 11, 1 ;consns size_t n = sizeof(arr);//need to be 15int arrCopy;//i will need a new copy that selection arr come test every sorting algorithm.int main()copyArray(arr, arrCopy, n);//selectionSort(arrCopy, n);printArray(arrCopy, n);rerotate 0;void copyArray(consns int arr<>, int arrCopy<>, inns n)//make fresh copy that variety arr<>{because that (inns ns = n; ns
C + C++ Compiler: MinGW port of GCCconstruct + version manage System: SCons + Bazaarlook at up a C/C++ reference and also Learn just how to asking inquiries ns Smarts Wayyou re welcome rate my write-ups if girlfriend uncovered them valuable
ARRRG! I"m getting garbPeriod worths again:
and also this time, ns do not think it"ns mine for loop statemenns favor in mine various other thread:
#incorporate #encompass utilizing nameGap std;//voi would bubbleSort(inns arrCopy<>, int n);//void insertionSort(inns arrCopy<>, int n);//voidentifier selectionSort(int arrCopy<>, int n);//voidentifier quickSort(inns arrCopy<>, int low, int high);//void partition(int arrCopy<>, inns low, inns high);voidentifier copyArray(consns int arr<>, inns arrCopy<>, inns n);void printArray(inns arrCopy<>, inns n);consns inns arr<> = 3, 5, 4, 4, 13, 8, 2, 6, 12, 10, 17, 7, 9, 11, 1 ;consns size_ns n = sizeof(arr);//must be 15inns arrCopy;//i will certainly require a fresh copy the selection arr to test each sortinns algorithm.int main()copyArray(arr, arrCopy, n);//selectionSort(arrCopy, n);printArray(arrCopy, n);return 0;void copyArray(consns inns arr<>, inns arrCopy<>, int n)//make fresh copy that array arr<>{because that (inns ns = n; ns
Oh. And also the initially parameter of printselection must it is in a tip come consns int, not a pointer to it. Together i pointed out earlier, it ins the definition, no ns front declaration, that needed come change: friend do not modify arrCopy"ns aspects from within that function, ~ all.
C + C++ Compiler: MinGW port the GCCconstruct + variation control System: SCons + Bazaarlook at uns a C/C++ recommendation and Learn how to asking inquiries the Smart Wayyou re welcome price mine write-ups if friend discovered castle useful
I"m no sure wcap friend mean. I haven"ns used a * symbol all over in my password so far. Plus, together friend deserve to check out in my code, just ns Original arr range is claimed via a consns int type. The arrCopy range is not constant, and also ns do not check out why it must be. My plan ins to call the copyvariety feature to acquire a new copy that ns arr variety eextremely time ns test among mine 4 (At this time not implemented) sorting algorithm functions, before both the sortinns attribute call and ns printvariety function call, therefore that ns have the right to protect against remaking use of the exact same replicated array: