Hi friends;
I've run into a problem trying to complete the below assignment:
Write a function called myName which returns (does not cout) your full name (e.g., "Bob Smith"). Write main to call the function and display the name on the screen. NOTE: Your name should not appear anywhere other than in the function myName.
The problem, as I understand it, is that the string MyName cannot be converted into an integer, and the function must use int to define itself.
I'm between a rock and a hard place, and I keep running into error code C2440: 'return' : cannot convert from 'std::string' to 'int'
#include <iostream>
#include <string>
using namespace std;
int MyName()
{
string MyName = "TK 421";
return MyName;
}
int main ()
{
MyName();
}
Also I used my skills in the internets to try to solve the problem, but the best I found was a bit of code that used a char function as a pointer to the string. Or something like that, but I didn't understand it and I'm not sure I'm allowed to do it for this problem. If it is the only way, could someone explain how it works please?