drop the public:: in both of the following two lines:
void public::sayhello()
void public::saygoodbye()
When that is done you will have an example of a program that uses two simple functions and uses a simple menu to allow user to make a single choice each time the program is done. Unfortunately, this program has little to do with classes. To have the two functions belong to a class you would need to do something like this:
Code:
#include <iostream.h>
//declare the class
class communicate
{
public:
void sayhello();
void saygoodbye();
};
//provide member function definitions
void communicate::sayhello()
{
cout<<"hello there!";
}
void communicate::saygoodbye()
{
cout<<"goodbye!";
}
int main()
{
int choice;
communicate talk;
cout<<"choose one:";
cout<<"[1] hello";
cout<<"[2] goodbye";
cin>>choice;
if(choice==1)
{
talk.sayhello();
}
if(choice==2)
{
talk.saygoodbye();
}
char dummy;
cin >> dummy;
return 0;
}
At some point you will want to start putting class definitions in your own header files so you can reuse classes in more than one program, but based on the code as posted, I think there are a few more lessons to be learned between now and then.