identifier not found c++

i get this is a simple problem, and i have spent almost 2 hours now looking for a fix but everything i try just creates more errors somehow. i only started learning c++ and im trying to make a simple calculator. i read somewhere about a prototype or something but im just not sure how to/able to fix this

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
28
29
30
31
32
#include "stdafx.h"
#include <iostream>


int main()
{
	std::cout << " .. text .. " << std::endl;
	getValueFromUser();
	yhteenLasku();
	std::cout << "Ending main()" << std::endl;

	return 0;

}

	int getValueFromUser()
	{
		std::cout << "  ..   text ..  ";
		int a;
		std::cin >> a;
		return a;
	}

	int yhteenLasku()
	{
		int x = getValueFromUser();
		int y = getValueFromUser();

		std::cout << x << " + " << y << " = " << x + y << std::endl;

		return 0;
	}
You can either move the definitions of getValueFromUser() and yhteenLasku() above main(), or you can declare them (add prototypes) above main() and leave the definitions below main() as-is.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>

int getValueFromUser();
int yhteenLasku();

int main()
{
	// ...
}

int getValueFromUser()
{
	// ...
}

int yhteenLasku()
{
	// ...
}
Last edited on
okay it works now, thanks!
Topic archived. No new replies allowed.