class, constructors, pointers to functions, need help please

This is a discussion on class, constructors, pointers to functions, need help please within the C++ Programming forums, part of the General Programming Boards category; Code: /* Terrance Lynch cpp memo 1 November 10, 2002 */ #include <iostream> using namespace std; class Name { public: ...

  1. #1
    CIS and business major
    Join Date
    Aug 2002
    Posts
    194

    Question class, constructors, pointers to functions, need help please

    Code:
    /*
    	Terrance Lynch
    	cpp memo 1
    	November 10, 2002
    */
    #include <iostream>
    using namespace std;
    
    class Name
    {
    public:
    	Name();
    	const char* GetName() const;
    
    private:
    	char NameInput[513];
    };
    
    class IntRequest
    {
    public:
    	IntRequest(const char *);
    	const int* GetInt() const;
    private:
    	int ThePhoneNumber;
    };
    
    class zipRequest
    {
    public:
    	zipRequest(const int *);
    	const int* getZip() const;
    
    private:
    	int theZipCode;
    };
    
    class testFour
    {
    public:
    	testFour(const char *, const int *, const int *);
    
    };
    
    
    int main()
    {
    	Name n1;
    	IntRequest ir1(n1.GetName() );
    	zipRequest zp1(ir1.GetInt() );
    	testFour t4(n1.GetName(), ir1.GetInt(), zp1.getZip() );
    
    
    
    
    	return 0;
    }
    
    Name::Name()
    {
    
    	cout << "Please enter your name: " << endl;
    	cin.getline(NameInput, sizeof(NameInput));
    
    
    }
    
    const char* Name::GetName() const
    {
    	return NameInput;
    }
    
    IntRequest::IntRequest(const char *NameInput)
    {
    	cout << NameInput << ", please enter you phone number: " << endl;
    	cin >> ThePhoneNumber;
    
    }
    
    const int* IntRequest::GetInt(int) const
    {
    	return ThePhoneNumber;
    
    }
    
    zipRequest::zipRequest()
    {
    	cout << "Please enter your zip code: " << endl;
    	cin >> theZipCode;
    
    }
    
    const int* zipRequest::getZip(int) const
    {
    	return theZipCode;
    }
    
    testFour::testFour(const char *NameInput, const int *ThePhoneNumber, const int *theZipCode)
    {
    
    	cout << NameInput << ThePhoneNumber << theZipCode << endl;
    
    }
    I just finished my c class, and now I'm learning c++, and I'm having a little difficulty. Please help, I keep getting three compiler errors I don't understand.

    Thank you

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>81: 'IntRequest::GetInt(int) const' is not a member of 'IntRequest'
    You have no member function matching this:
    >const int* IntRequest::GetInt(int) const
    But you do have one of these:
    >const int* GetInt() const;
    Did you mean to include/exclude the int as a parameter? I expect your meant to change line 81 to
    >const int* IntRequest::GetInt() const

    >>87: 'zipRequest::{()' is not a member of 'zipRequest'
    Similar problem to above. You have no function prototype in the class for this function. Try adding zipRequest(); to the public section of the class.

    >>94: 'zipRequest::getZip(int) const' is not a member of 'zipRequest'
    ... and again.

    Remember that the parameters need to match between the function prototype and the function header.

    You may also find some other errors when you fix these, but I'll leave those for you to work on for now
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 04:01 PM
  2. Replies: 3
    Last Post: 10-31-2005, 11:05 AM
  3. question about DLL's and class functions
    By btq in forum Windows Programming
    Replies: 2
    Last Post: 02-25-2003, 05:08 AM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM
  5. Replies: 4
    Last Post: 09-12-2001, 02:05 PM

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