You really need to review your textbook and your course notes on how to declare and implement class member functions. This link may also help: http://www.cplusplus.com/doc/tutorial/classes/
It's okay to scream. (I recommend you go do it and come back.)
The way things are written is confusing because a constructor is a funny kind of function that does not have a return type. A destructor doesn't have one either.
All other functions must always have their return type listed.
#include <iostream>
usingnamespace std;
class Greeting
{
string name;
// I'm a constructor, so I have no return type. (I return a Greeting.)
Greeting( string a_name );
// I'm a normal function (well, a method), so I must have a return type.
void greet();
};
// Now the constructor's definition. Again, I have no return type.
Greeting::Greeting( string a_name )
{
name = a_name;
// (because I automatically return a Greeting)
}
// And again, I'm a normal method, so I must have a return type.
void greet()
{
cout << "Hello " << name << "!\n";
// (void functions don't need a "return" statement)
}
int main() // (see my return type? it's an int)
{
Greeting a( "Niles" );
a.greet();
return 0;
}
Hope this helps.
lots of edits to make the code something you can actually run