Sunday 19 January 2014

Can void return a value

Posted by Саша 16:35, under | No comments


Can void return a value? Can void return a value?

can void return a value? and does string getCourseName and return courseName do different things or they do the samething?

example:

string getCourseName()
{
return courseName;
}

void displayMessage()
{
cout << "Hello" << getCourseName();
}


Other Answers:




void does not return anything. You can use "return;" in displayMessage() to exit that method, but that's all it will do.

getCourseName() is the method that returns a string variable called courseName









0 коммент.:

Post a Comment