Help finding solution to illegal operator

This is a discussion on Help finding solution to illegal operator within the C++ Programming forums, part of the General Programming Boards category; Hello everyone. In the following code, I get a C2296 error when I try to compile in VC++ 6.0. The ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    5

    Help finding solution to illegal operator

    Hello everyone.

    In the following code, I get a C2296 error when I try to compile in VC++ 6.0. The error reads: error C2296: '/' : illegal, left operand has type 'double [10]'. I have tried to find a solution, but I do not understand why this happens. I have never had this problem before. If anyone has suggestions, I would appreciate the help.
    Here is the code:

    Code:
    #include <iostream>
    #include <iomanip>
    #include <fstream>
    #include <cmath>
    	
    void mortgageCalc();
    					
    using namespace std;
    
    int main()
    {
    	void mortgageCalc();
    	return 0;
    }
    //******************		
    void mortgageCalc()
    {
    
       const int MAX_SIZE=10;
       int index=0;           //account record
       int total=0;
       int loan[MAX_SIZE];
       int month[MAX_SIZE];
       double rate[MAX_SIZE];
       double monthlyPayment;
       double totalPayment;
       double ratem;
       double expm;
       ifstream inFile; 
    
        inFile.open("mortgage.txt");            //get txt file
        
        if (!inFile.fail())					
        {                                      
            cout<< setiosflags(ios::fixed | ios::showpoint)
    	       << setprecision (2);
            cout<<endl;
    						
           ratem=rate / 1200.0;
           expm=(1.0 + ratem);
          
           monthlyPayment=(ratem*pow(expm,month)*loan) / (pow(expm,month)-1.0);
    
          totalPayment= monthlyPayment*month
          
          cout<<"\t Here are the mortgage loan calculations for"<<endl;
    	  cout<<"\t the following accounts:  "<<endl;
          cout<<endl;
          
          while (!inFile.eof() && index < MAX_SIZE)
         {   
    											//import record
                      inFile>>loan[index]>>month[index]>>rate[index];
    				 
    	 index++;
          }
                     
    
    
          for (index=0; index < MAX_SIZE; index++)
         {
    
          cout<<"Account Number "<<index<<" borrowed $ "<<loan<<endl;
         cout<<"The monthly payment for this account is $"<<monthlyPayment<<endl;
         cout<<"The total payment amount for the loan is $"<<totalPayment<<end;
         cout<<endl;
        cout<<endl;
    			
    				}
    }						 
        else
        {                                    
            cout << "File not read"<< endl;
        }								   
         
    }										//end of function

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Code:
    int loan[MAX_SIZE];
    /* ... */
    monthlyPayment=(ratem*pow(expm,month)*loan) / (pow(expm,month)-1.0);
    You need to specify a particular element from the array to use in the equation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 12:55 PM
  2. class initialization and the = operator
    By krygen in forum C++ Programming
    Replies: 3
    Last Post: 01-26-2005, 11:44 PM
  3. Destructor - Execution problem
    By triste in forum C++ Programming
    Replies: 16
    Last Post: 09-26-2004, 01:57 PM
  4. quick c++ operator question
    By pkananen in forum C++ Programming
    Replies: 3
    Last Post: 12-11-2001, 05:46 PM
  5. int vs BIG INT
    By rumi_red in forum C++ Programming
    Replies: 1
    Last Post: 10-30-2001, 03:15 AM

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