954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

An extra error in a book exercise?

The exercise tells me to find the error in this code

int g()
{
cout << "Inside function g" << endl;
int h()
{
cout << "Inside function h" << endl;
}
}

The listed error is that function h should not be defined inside of function g. I understand that. But aren't functions h and g supposed to return an int? It's not listed in the book answer section as an error, but it seems fishy.

Spiffy P Mcgee
Newbie Poster
8 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

Yes they should return an int, but the author probably omitted that just to simplify the code and illustrate the intended problem.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: