Thread: What is wrong with the code??

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    6

    Unhappy What is wrong with the code??

    ************** START OF THE CODE *********************
    Code:
    #include<iostream>
    #include<fstream>
    using namespace std;
    
    ifstream fin("c:/files/data.txt");
    
    class BankLoanApproval{
    	int records;
    	double yr_income;
    	double loan_amount;
    	int term_of_loan;
    	int cust_status;
    public:
    	
    	BankLoanApproval (int r, double y, double la, int t, int cs); 
    	int GetRecords() {return records;}
    	double GetIncome() {return yr_income;}
    	double GetLoanAmount() {return loan_amount;}
    	int GetTerm() {return term_of_loan;}
    	int GetStatus() {return cust_status;}
    	int SetRecords(int n_records)
    	{
    		return records=n_records;
    	}
    	void SetIncome(double new_income)
    	{
    		yr_income=new_income;
    	}
    	void SetLoan(double new_amount)
    	{
    		loan_amount=new_amount;
    	}
    	void SetTerm(int term)
    	{
    		term_of_loan=term;
    	}
    	void SetStatus(int c_status)
    	{
    		cust_status=c_status;
    	}
    };
    
    BankLoanApproval::BankLoanApproval(int r, double y, double la, int t,int cs)
    {
    	records = r;
    	yr_income = y;
    	loan_amount= la;
    	term_of_loan = t;
    	cust_status = cs;
    }
    
    void main()
    {
    	if (!fin)
    	{
    		cout << " Can not Open the input file with customer data!!"<< endl;
    		exit(1);
    	}
    	int count;
    	int rec;
    	double income;
    	double amount;
    	int term;
    	int status;
    	fin >> rec >> income >> amount >> term >> status;
    	BankLoanApproval loan(rec, income, amount, term, status);
    	count = loan.SetRecords(rec);
    	cout << count << "\n";
    	fin.close();
    	
    	
    	for(count; count > 0 ; count--)
    	{
    		fin >> rec >> income;
    		loan.SetIncome(income);
    		cout << loan.SetIncome();
    		loan.SetLoan(amount);
    		cout << loan.SetLoan();
    		loan.SetStatus(status);
    		cout << loan.SetStatus();
    		loan.SetTerm(term(;
    		cout << loan.SetTerm();
    	}
    	
    }
    **************** END OF CODE ************************

    this are the error by the compiler can't figure it why?

    --------------------Configuration: assigment2 - Win32 Debug--------------------
    Compiling...
    BankLoan.cpp
    C:\assigment2\BankLoan.cpp(76) : error C2660: 'SetIncome' : function does not take 0 parameters
    C:\assigment2\BankLoan.cpp(78) : error C2660: 'SetLoan' : function does not take 0 parameters
    C:\assigment2\BankLoan.cpp(80) : error C2660: 'SetStatus' : function does not take 0 parameters
    C:\assigment2\BankLoan.cpp(82) : error C2660: 'SetTerm' : function does not take 0 parameters
    Error executing cl.exe.

    BankLoan.obj - 4 error(s), 0 warning(s)
    ----------------------------------------------------------------------------------

    I am suppose to read the parameters from a file.

    &#91;code]&#91;/code]tagged by Salem

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    You called overloaded functions without parameters. Every Set function requires one or more parameters.

    Kuphryn
    Last edited by kuphryn; 10-28-2002 at 05:11 PM.

  3. #3
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378
    Compiler Error C2660
    'function' : function does not take number parameters

    The specified function was called with an incorrect number of actual parameters.

    Tips

    The most typical cause of this error is calling a function with the incorrect number of actual parameters. The following example demonstrates this:
    void func( int, int );
    void main()
    {
    func( 1 ); // error, func( int ) not declared
    func( 1, 0 ); // OK, func( int, int ) was declared
    }

    A problem similar to the one shown above occurs when you mistakenly call a Windows API function directly from within an MFC member function, rather than calling the equivalent MFC member function of the same name. Since the two functions are identical in name this error may occur frequently. Either of the two following methods will solve this error:
    Adjust the function call to conform to the format of the member function call.


    Use the scope resolution operator (: to tell the compiler to look for the function name in the global name space.

    Good Luck!!
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  4. #4
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    code tags are good for you, btw : )

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    Code:
    void main()
    {
    if (!fin)
    {
    cout << " Can not Open the input file with customer data!!"<< endl;
    exit(1);
    }
    int count;
    int rec;
    double income;
    double amount;
    int term;
    int status;
    fin >> rec >> income >> amount >> term >> status;
    BankLoanApproval loan(rec, income, amount, term, status);
    count = loan.SetRecords(rec);
    cout << count << "\n";
    fin.close();
    Now we're cooking!!!

    'void main()'. Don't ever use it again!!!

    It's 'int main(void)', period.

    Next, what's up with ' if (!fin)'?

    ifstream fin(filename, ios:: open); (At the very least.)
    if (!fin){
    // error message
    }

    >count = loan.SetRecords(rec);

    There's no 'loan' object instantiated in main().

    'BankLoanApproval loan;'

    Now, 'loan' has been instantiated. (Put it in main()).

    (No matter how daunting it seems, a "class" is simply a user-defined 'type'. Once the 'type' has been declared/defined, you use it as you would use any other type, except that you must use the "dot" operator to access the member functions.)

    You've done that in your functions, but you MUST instantiate your object in main().

    All right. Run with that and see where it takes you.

    Good luck!

    -Skipper
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  6. #6
    its not int main(void) WTH lol , ok C++ says its int main() , and at the end of your main, return 0; simple as that, learn it, breath it, urinate it

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    'int main(void)' is completely legit.

    'int main()' is also legit.

    'return 0;' is optional in C++ (not in C, however).

    (Sorry, no urinating. Well...immediately, anyway. )

    -Skipper
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  8. #8
    Returning a value to the operating system is a relatively unimportant and little used feature, but the C++ standard does require main() be declared as show. ( int main() return 0

    -Jesse Libetry

  9. #9
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    Hehe, here it goes again. Unless I got the wrong end of the stick somewhere Returning a value to the operating system happens, you don't get to choose if that 'feature' gets used. If you don't tell the program what to return, then that unimportant and little used feature will return something for you that is undefined.
    Demonographic rhinology is not the only possible outcome, but why take the chance

  10. #10
    ok, are you too freaking lazy to write:
    Code:
    #include <iostream>
    
    int main()
    {
       std::cout << "Your lazy.\n";
       return 0;
    }
    instead of the easy way out?

    Code:
    #include <iostream>
    
    int main(void)
    {
       std::cout << "Yes indead.\n";
    }

  11. #11
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    In c++, the return statement at the end of main is optional. Read it here, text taken directly from the standard, therefore no arguments please
    ISO/IEC 14882:1998(E)
    3.6.1 Main function
    5 A return statement in main has the effect of leaving the main function (destroying any objects with auto-matic storage duration) and calling exit with the return value as the argument. If control reaches the end of main without encountering a return statement, the effect is that of executing
    return 0;
    And no, I'm not too lazy to write it, but what's the point if it's a guaranteed feature?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  12. #12
    well its a good programming standard just incase you want to return something. Who knows, when it comes to you having to return something for main, you might have forgoten how hehe,

  13. #13
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>you might have forgoten how
    Now that's the best argument for this I've heard in a long time I can picture myself 10 years from now, a guru in all that is C++, doing a google search for how to use leave(). no wait, it's getout()... no.... oh, whatever!
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  14. #14
    hahahahah, yes, i havent made a good joke in a while, im so proud of myself

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is wrong in this simple code
    By vikingcarioca in forum C Programming
    Replies: 4
    Last Post: 04-23-2009, 07:10 AM
  2. what is wrong with this code please
    By korbitz in forum Windows Programming
    Replies: 3
    Last Post: 03-05-2004, 10:11 AM
  3. I cant find what is wrong with this code
    By senegene in forum C Programming
    Replies: 1
    Last Post: 11-12-2002, 06:32 PM
  4. Anyone see what is wrong with this code?
    By Wise1 in forum C Programming
    Replies: 2
    Last Post: 02-13-2002, 02:01 PM
  5. very simple code, please check to see whats wrong
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-10-2001, 12:51 AM