473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

confusing errors!

5
ok so i got my class to work now im having confusing errors with this:
Expand|Select|Wrap|Line Numbers
  1. void sort(Student stu[], int parameter, int count)
  2. {
  3.    Student temp;
  4.  
  5.    bool finished = false;
  6.    while (!finished)
  7.    {
  8.       finished = true;
  9.       for (int i = 0; i< count-1; i++)
  10.       {
  11. [79]       if(Student[i].compareTo(Student[i+1], parameter) == true)
  12. [80]       {
  13.     temp = stu[i];
  14.     stu[i] = stu[i+1];
  15.     stu[i+1] = temp;
  16.     finished = false;
  17.              }
  18.      }
  19.   }
the errors are
1>h:\cs 215\program 2\program 2\program 2.cpp(79) : error C2059: syntax error : '['
1>h:\cs 215\program 2\program 2\program 2.cpp(80) : error C2143: syntax error : missing ';' before '{'

i dont know what the problem with my synatx could be.

and my compareTo function is:
Expand|Select|Wrap|Line Numbers
  1. bool Student::compareTo (Student stu2, int parameter)
  2. {
  3.     if (parameter ==1)
  4.     {
  5.         if(FirstName < stu2.FirstName)
  6.             return false;
  7.         else 
  8.             return true;
  9.     }
  10.     if (parameter ==2)
  11.     {
  12.         if(LastName < stu2.LastName)
  13.             return false;
  14.         else 
  15.             return true;
  16.     }
  17.     if (parameter ==3)
  18.     {
  19.         if(GPA < stu2.GPA)
  20.             return false;
  21.         else
  22.             return true;
  23.     }
  24.     if (parameter ==4)
  25.     {
  26.         if(age < stu2.age)
  27.             return false;
  28.         else
  29.             return true;
  30.     }
Feb 20 '08 #1
1 1335
gpraghuram
1,275 Expert 1GB
Hi,
Expand|Select|Wrap|Line Numbers
  1. //if(Student[i].compareTo(Student[i+1], parameter) == true)
  2. //Why are u using Vraiable type to access a variable.
  3. //it is like specifying int[i];
  4.  
  5. //You should use the variable name instead of variable type
  6.  
  7. //it should be
  8. stu[i].compareTo(stu[i+1], parameter) == true)
  9. {
  10. }
  11.  
Raghuram
Feb 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Marc | last post by:
Hi all, I was using Tkinter.IntVar() to store values from a large list of parts that I pulled from a list. This is the code to initialize the instances: def initVariables(self): self.e =...
65
by: Pmb | last post by:
I'm confused as to what the compiler error message I'm getting is refering to. Can someone take a gander and let me know what I did wrong? The program is below. When I compile it I get the...
6
by: blueblueblue2005 | last post by:
Hi, I am reading the const function definition part in Deitel book, it says : Defining as const a member function that calls a non-const member function of the class on the same instance of the...
16
by: Shelly | last post by:
(posted previously on comp.lang.php but no response received. Cross-posted in the dreamweaver forum) I am confused about what goes on with method POST. Here is an overview of a my code,...
8
by: ImOk | last post by:
I just have a question about trapping and retrying errors especially file locking or database locks or duplicate key errors. Is there a way after you trap an error to retry the same line that...
1
by: abcbook | last post by:
Can anyone explain a get around for this .js file I’m trying to create or tell me if there is one or what am I missing. I Do Not what to put the form Directly on the HTML Page. This .js file will...
10
by: heng | last post by:
#include<iostream> #include<string> using namespace std; class A { public: int x; int y; A(int y_){y=y_;}
2
by: d3vkit | last post by:
Okay so I can NOT get my while loop to work. It's the most confusing thing I've ever come across. It was working fine and then suddenly, nothing. No error. The page just dies. I am using PHP5 with...
7
by: Andy B | last post by:
I saw this in the set accessor of a property: Set(ByVal value As DataSet) What exactly does the stuff in the () mean? VS complained about it not being there when I took it out not knowing...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.