Illegal character errors

This is a discussion on Illegal character errors within the C++ Programming forums, part of the General Programming Boards category; I am sorry my code looks really long but I got some errors in this part that I coudn't really ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    58

    Illegal character errors

    I am sorry my code looks really long but I got some errors in this part that I coudn't really fiqure them out, which they are the following:



    [CODE]Warning W8054 Program3.cpp 115: Style of function definition is now obsolete
    Error E2316 Program3.cpp 115: 'healthClubMaintain::approvalExerciseToClient()' is not a member of 'healthClubMaintain'



    for this part

    Code:
    void healthClubMaintain::approvalExerciseToClient(exerciseName1){
    	int flag = 0; // set flag to off
    
    	for(int i=0; i<15; i++){
    		if (names[i] == exerciseName1){
    			flag = 1;
    			break ; 
    		}
    	}
    	
    		if (flag){
    			cout<< "Your number is at subscript position " << i << endl;
    		}
    	
    		else{
    			cout<< "Sorry, I could not find your number in this array."<<endl;
    		}
    	 
    }

    This is my original code


    Code:
    #include <iostream>
    using namespace std;
    
    class healthClubMaintain{
    
    private:
    	 string names[15];
    	 int idnumbers[15];
    	 
    	 string exerciseNames[15];
    	 int exerciseidNumbers[15];
    
    	 int counter,counter2,counter3,counter4,counter5,i,s,q,w,x,z,flag1;
    	 string mystr;
    
    
    public:
    	void addClient(string,int);
    	void printClient();
    	void printClientID();
    	void addExercise(string,int);
    	void healthClubMaintain::printExercise();
    	void approvalExerciseToClient(string);
    	healthClubMaintain() {  // default constructor
        counter5 = 0;
    	 counter4 = 0;
        counter3 = 0;
    	 counter2 = 0;
    	 counter=0;
    }
    
    };
    
    
    void healthClubMaintain::addClient(string clientName, int clientIDNumber){
    	mystr = clientIDNumber;
    	
    	if (counter<15){
    		names[counter]=clientName;
    		counter++;
    	}
    	
    	while(counter3<10){
    		if ( (mystr[counter3] != '1') || (mystr[counter3] != '2') ||(mystr[counter3] != '3') || (mystr[counter3] != '4') ||(mystr[counter3] != '5') || (mystr[counter3]!= '6')||(mystr[counter3] != '7') || (mystr[counter3] != '8')||(mystr[counter3] != '9'))
    		{
    			flag1=1;
    			break;
    		}
    		counter3++;
    	}
    	
    	if(flag1){
    		if (counter2<15){
    			idnumbers[counter2]=clientIDNumber;
    			counter2++;
    		}
    	}
    	else{
    		cout << " Error!"<<endl;
    	}
    	
    	
    }
    	
    
    
    void healthClubMaintain::printClient(){
    		
    		i=0;
    		s=0;
    		while(i<counter){
    			cout << "client's name:  " << names[i]<<endl;
    			cout << "ID#:  " << idnumbers[s]<<endl;
    			cout << "  " <<endl;
    			i++;
    			s++;
    		}
    
    	
    }
    
    void healthClubMaintain::addExercise(string exerciseName, int exerciseNumber){
    	
    	if (counter4<15){
    		exerciseNames[counter4]=exerciseName;
    		counter4++;
    	}
    	
    
    	if (counter5<15){
    		exerciseidNumbers[counter5]=exerciseNumber;
    		counter5++;
    	}
    
    	
    }
    	
    
    
    void healthClubMaintain::printExercise(){		
    		q=0;
    		w=0;
    		while(q<counter4){
    			cout << "Exercise's name:  " << exerciseNames[q]<<endl;
    			cout << "Exercise#:  " << exerciseidNumbers[w]<<endl;
    			cout << "  " <<endl;
    			q++;
    			w++;
    		}
    
    	
    }
    
    
    void healthClubMaintain::approvalExerciseToClient(exerciseName1){
    	int flag = 0; // set flag to off
    
    	for(int i=0; i<15; i++){
    		if (names[i] == exerciseName1){
    			flag = 1;
    			break ; 
    		}
    	}
    	
    		if (flag){
    			cout<< "Your number is at subscript position " << i << endl;
    		}
    	
    		else{
    			cout<< "Sorry, I could not find your number in this array."<<endl;
    		}
    	 
    }
    
    				
    
    
    
    int main(){
    
    int number,loop=0;
    int clientIDNumber,exerciseNumber,clientIDA,programNumberA,exerciseNumber1;
    string clientName,exerciseName,approvalName,exerciseName1;
    healthClubMaintain Club;
    
    while ( loop==0){
    
    	cout<< "Select one of the following option:"<<endl;
    	cout<< "(1) Add a new client to the program"<<endl;
    	cout<< "(2) Display All clients in the program"<<endl;
    	cout<< "(3) Add a new exercises in the program"<<endl;
    	cout<< "(4) Display All exercises in the program"<<endl;
    	cin >> number;
    
    
    if ( number ==1 ){
    	cout << "Insert the client's name" << endl;
    	cin >> clientName;
    	cout << "Insert a new ID" << endl;
    	cin >>clientIDNumber;
    	Club.addClient(clientName,clientIDNumber);
    }
    
    if ( number == 2){
    	 Club.printClient();
    }
    
    if ( number == 3){
    	cout << "Insert the exercise's name" << endl;
    	cin >> exerciseName;
    	cout << "Insert a Exercise Number" << endl;
    	cin >>exerciseNumber;
    	Club.addExercise(exerciseName,exerciseNumber);
    }
    
    if ( number == 4){
    	 Club.printExercise();
    }
    
    if ( number == 5){
    	cout << "Insert the exercise's name" << endl;
    	cin >> exerciseName1;
    	cout << "Insert a Exercise Number" << endl;
    	cin >>exerciseNumber1;
    	Club.approvalExerciseToClient(exerciseName1);
    
    
    }
    
    }
    }
    Last edited by aama100; 02-21-2008 at 08:51 PM.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Give the function parameter a type. Move the i declaration out of the loop if you want to use it after the loop. Match up your curly braces.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    When you see something like this:
    Code:
    }
    
    }
    }
    Then you have an indentation problem.
    Refer to http://cpwiki.sf.net/Indentation for indenting or select all code and press Alt+f8 inside visual studio to indent better.

    All arguments must have a type in C++, so you get that error because you omitted the type, hence the compiler skipped the argument but couldn't find a function in the class that takes no arguments.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. get wide character and multibyte character value
    By George2 in forum C++ Programming
    Replies: 27
    Last Post: 01-27-2008, 04:10 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. syntax error when defining vectors
    By starkhorn in forum C++ Programming
    Replies: 5
    Last Post: 09-22-2004, 12:46 PM
  4. Character handling help
    By vandalay in forum C Programming
    Replies: 18
    Last Post: 03-29-2004, 04:32 PM
  5. mygets
    By Dave_Sinkula in forum C Programming
    Replies: 6
    Last Post: 03-23-2003, 06:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21