Expression syntax error

This is a discussion on Expression syntax error within the C++ Programming forums, part of the General Programming Boards category; I have this error in my code. Can anyone figure out what's the problem ? Error E2188 workingArea2.cpp 57: Expression ...

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

    Expression syntax error

    I have this error in my code. Can anyone figure out what's the problem ?

    Error E2188 workingArea2.cpp 57: Expression syntax in function CRectangle::check()

    Code:
    #include <iostream>
    using namespace std;
    
    // declaring a class
    class CRectangle 
    {
    	public:
        
        	void set_values(int, string);
    		string check();
    	 	string check2();
    
    	private:
    	
    		int x,flag,counter;
    		string y;
    		size_t found,found1,found2,found3,found4,found5,found6,found7,found8,found9,found10,found11;			
    		
    };
    
    
    void CRectangle::set_values (int a, string b)
    {
      	x = a;
      	y = b;
    }
    
    // test three conditions
    string CRectangle::check()
    {
            found = y.find('4'); 
    	found1 = y.find('5'); 
    	found2 = y.find('8'); 
    	found3 = y.find('9'); 
    	found4 = y.find('A'); 
    	found5 = y.find('L'); 
    	found6 = y.find('P'); 
    	found7 = y.find('R');
    	found8 = y.find('T'); 
    	found9 = y.find('V'); 
    	found10 = y.find('W'); 
    	found11 = y.find('X');
    	flag =0;
    	counter=0;
    	if(x != 6)
    	{
    		cout << "false"<< endl;
    	}
    		
    	else if ((found==string::npos)||(found1==string::npos))
    				cout << "NOOO! please"<<endl;
    		  else if ((found2==string::npos)&&(found3==string::npos))
    			    	cout << "NOOO! please" << endl;
    				 else  					
    						while(counter<4)
    						{
    							if (found4==string::npos)||(found5==string::npos)||found6==string::npos)||(found7==string::npos)||found8==string::npos)||(found9==string::npos)||found10==string::npos)||(found11==string::npos))
    							{
    								flag=1;
    								cout << "good"<<endl;
    								break;
    							}
    							counter++;
    						}
    								  			
    										
    
    								
    	return  y;
    }
    
    
    int main () {
      	
    	int length;
    	string codeNumber;
            string mystr = codeNumber;
    	
    
    	
    	cout << "Insert a code of 6 characters:";
    	cin >> codeNumber;
    	length = codeNumber.length();
      
       	CRectangle rect;
       	rect.set_values (length,codeNumber);
            rect.check();
       
       	return 0;
    }
    Last edited by aama100; 02-04-2008 at 05:52 PM.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Care to highlight line 52?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    It must be around here. if you look to the syntax of this line I am using the same in the previous conditions

    Code:
    							if (found4==string::npos)||(found5==string::npos)||found6==string::npos)||(found7==string::npos)||found8==string::npos)||(found9==string::npos)||found10==string::npos)||(found11==string::npos))

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    2,023
    Well you're missing a open paren.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by aama100 View Post
    It must be around here. if you look to the syntax of this line I am using the same in the previous conditions

    Code:
    							if ((found4==string::npos)||(found5==string::npos)||(found6==string::npos)||(found7==string::npos)||(found8==string::npos)||(found9==string::npos)||(found10==string::npos)||(found11==string::npos))
    I hope your logic is right, this should be syntactic.

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    guys you are the best ppl ever Thanks so much! I have been stuck for like half an hour.. I didnt expect these little things..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  2. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM

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