This makes it sound like you are confused about function declaration (when you precede the function name with a type), and function definitions (when you tell the compiler what the function should do).
But,I tried that before but than it gives an error regarding no return statement,When I inserted "return 0;"it works. but should I do this?? as it is a string fuunction, why should I return an integer "0"? By the way, I like the 2nd option.
You get to declare what TYPE any function is. If you don't wany it to return anything look into the void type. If you want it to return something then return the appropriate data type that you want returned. Just like declaring any variable you can also declare any function in the same manner. You just have to make sure that said function has a return of the type of which you declared it. IE.
In this manner you can also create any type of function. It can be
int a = 10; // just for example purposes
return a; // the function must return a variable that matches it's type.
On top of that your functions can actually be declared as and return structures and classes that you defined as well. I hope I didn't confuse you, as this is an extremely important aspect to programming in C++.
int Aint = 10;
string Astring = "some arbitrary value";
} // as long as you #include <string>
float Afloat = 3.14;
double Adouble = 0.0012353;