If this isn't a nested function then what is it?

So i know in c++ you cannot right nested functions. But in this code ive been following GetGuess() is called in PlayGame() then i call PlayGame() in main and it will do both functions. If thats not a nested function then what is it exactly?

what i am thinking is that it is okay to call a function in another function?
But it's not okay to define a function within a function?(hence this is called a nested function?)
is that correct?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
std::string GetGuess() {
	
	int CurrentTry = BCGame.GetCurrentTries();

	std::cout << "Try " << CurrentTry << ". Enter your guess: ";
	std::string Guess;
	std::getline(std::cin, Guess);

	return Guess;
}

void PlayGame() {

	// instance of game (instantiating)
	int MaxTries = BCGame.GetMaxTries();

	constexpr int NUMBER_OF_TURNS = 5;

	for (int i = 1; i <= MaxTries; i++) {
	
		std::string Guess = GetGuess();

		std::cout << "Your guess was: " << Guess << std::endl;
		std::cout << std::endl;
	}
	return;
	}
Correct.

A function can even call itself. That is recursion.


Note: C++11 has lambda closures. They are defined (and called) inside functions.
Topic archived. No new replies allowed.