Advertisement

04.14.2008 at 03:22PM PDT, ID: 23322078
[x]
Attachment Details

How to use sort() function in classes

Asked by jhuntii in C++ Programming Language

Tags: C++

So my question is, I have a program that I'm writing to one of my classes at school, and I need to be able to pass an array to a sort function in my user defined class from my main().  What I can't figure out is how I make it do it's thing.  First I'm putting it into a void function void RainFall::sort( ), and then want then want to use it in a print function.  Here is what I have right now...hopefully it's enough to answer my question.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
void RainFall::sort( )
{
	int chosen, temp;
	int MAX = 12;
 
	for ( int leftmost = 0; leftmost < MAX; leftmost++ )
	{
		chosen = leftmost;
		for ( int j = leftmost + 1; j < MAX; j++ )
		if (rf.readActual[j] < rf.readActual[chosen])
		chosen = j;
		temp = rf.readActual[chosen];
		rf.readActual[chosen] = rf.readActual[leftmost];
		rf.readActual[leftmost] = temp;
	}
}
 
Loading Advertisement...
 
[+][-]04.14.2008 at 03:33PM PDT, ID: 21354508

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 04:14PM PDT, ID: 21354777

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 10:44PM PDT, ID: 21356186

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.14.2008 at 11:51PM PDT, ID: 21356445

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 01:32AM PDT, ID: 21356898

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 03:12PM PDT, ID: 21363292

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 04:01PM PDT, ID: 21363525

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 04:07PM PDT, ID: 21363545

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.16.2008 at 12:33AM PDT, ID: 21365504

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C++ Programming Language
Tags: C++
Sign Up Now!
Solution Provided By: Infinity08
Participating Experts: 4
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628