Thread: I need to fix these errors

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

    I need to fix these errors

    I made up a small program in my mind.. and I got some errors in the code ... These errors are where I have problems with that once I know how to fix them I will be able to do bigger things

    Code:
    class healthClubMaintain{
    
    private:
    	int takingnumber;	
    	
    public:
    	multip(int);
    	printNumber(int);
    };
    
    
    int healthClubMaintain::multip(number)
    {
    	takingnumber = number;
    	takingnumber = takingnumber * 10;
    	return takingnumber;
    }
    
    
    void healthClubMaintain::printNumber(number)
    {
    	cout << "The number before is:" << number <<endl;
    	cout << "The number after is:" << takingNumber << endl;
    }	
    
    
    
    int main(){
    
    int Number;
    cout<< "Enter any Number"<<endl;
    cin >> number;
    
    multip (number);
    printNumber(number);
    
    }
    Last edited by aama100; 02-13-2008 at 09:45 PM.

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    what kind of errors? compiler errors? runtime errors?

    post the actual errors also.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    Mostly to be compiler errors like this following for this code..

    Code:
    Warning W8054 workingArea3.cpp 12: Style of function definition is now obsolete
    Warning W8054 workingArea3.cpp 20: Style of function definition is now obsolete
    Error E2316 workingArea3.cpp 21: 'healthClubMaintain::printNumber(int)' is not a member of 'healthClubMaintain'
    Error E2451 workingArea3.cpp 22: Undefined symbol 'cout' in function healthClubMaintain::printNumber(int)
    Error E2451 workingArea3.cpp 22: Undefined symbol 'number' in function healthClubMaintain::printNumber(int)
    Error E2451 workingArea3.cpp 22: Undefined symbol 'endl' in function healthClubMaintain::printNumber(int)
    Error E2451 workingArea3.cpp 23: Undefined symbol 'takingNumber' in function healthClubMaintain::printNumber(int)
    Warning W8070 workingArea3.cpp 24: Function should return a value in function healthClubMaintain::printNumber(int)
    Error E2451 workingArea3.cpp 31: Undefined symbol 'cout' in function main()
    Error E2451 workingArea3.cpp 31: Undefined symbol 'endl' in function main()
    Error E2451 workingArea3.cpp 32: Undefined symbol 'cin' in function main()
    Error E2451 workingArea3.cpp 32: Undefined symbol 'number' in function main()
    Error E2268 workingArea3.cpp 34: Call to undefined function 'multip' in function main()
    Error E2268 workingArea3.cpp 35: Call to undefined function 'printNumber' in function main()

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Prefix the cout, cin and endl with std:: like 'std::cout' or put using namespace std; at the top of your main.

    Also, #include <iostream>

    int healthClubMaintain::multip(int number)

    void healthClubMaintain::printNumber(int number)

    and indent your code.
    Last edited by robwhit; 02-13-2008 at 10:09 PM.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    58
    This is the updated code, but I still have these following errors:

    Code:
    Error E2451 workingArea3.cpp 24: Undefined symbol 'takingNumber' in function healthClubMaintain::printNumber(int)
    Error E2268 workingArea3.cpp 35: Call to undefined function 'multip' in function main()
    Error E2268 workingArea3.cpp 36: Call to undefined function 'printNumber' in function main()
    Code:
    #include <iostream>
    using namespace std;
    
    class healthClubMaintain{
    	private:
    		int takingnumber;	
    	public:
    		int multip(int);
    		void printNumber(int);
    };
    
    
    int healthClubMaintain::multip(int number)
    {
    	takingnumber = number;
    	takingnumber = takingnumber * 10;
    	return takingnumber;
    }
    
    
    void healthClubMaintain::printNumber(int number)
    {
    	cout << "The number before is:" << number <<endl;
    	cout << "The number after is:" << takingNumber << endl;
    }	
    
    
    
    int main(){
    
    	int number;
    	cout<< "Enter any Number"<<endl;
    	cin >> number;
    
    	multip(number);
    	printNumber(number);
    
    }

  6. #6
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    takingnumber and takingNumber are different
    C++ is case sensetive

    PS. To call member function - you need to have an object

    healthClubMaintain club;
    club.multip(number);
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  2. Strange/false errors
    By Ganoosh in forum Windows Programming
    Replies: 8
    Last Post: 10-20-2005, 04:54 PM
  3. strange errors?
    By egomaster69 in forum C Programming
    Replies: 6
    Last Post: 12-21-2004, 06:13 PM
  4. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 08:18 PM
  5. Errors when including winsock2.h
    By skiingwiz in forum Windows Programming
    Replies: 2
    Last Post: 12-27-2002, 07:32 PM