too few arguments to function

whenever I try to compile it to a .exe it gives me this error:
1
2
3
4
5
6
C:\C++>
g++ classBasics.cpp -o classBasics.exe
classBasics.cpp: In function 'int main()':
classBasics.cpp:40:18: error: too few arguments
(std::string)'
classBasics.cpp:17:5: note: declared here 


this is what is what I tryed:

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <conio.h>
#include <string>

using namespace std;
class exampleClass2{
	public:
		void example2(){
		string exampleString1 = "This test works. You have passed.";
		
		
		}


};

int exampleFunction (string exampleString1){	
	cout << exampleString1 << endl;

}

class exampleClass1{
	public: // cohlen not a semi-cohlen.
		void example1(){
		// void means it is not going to return nothing

			cout <<"This, the text, is a example"<< endl;
		}

};

int main(){

	exampleClass1 exampleObject;
	exampleObject.example1();
	
	cout << "" << endl;
	cout << "" << endl;
	
	exampleFunction();

	cout << "" << endl;
	cout << "" << endl;


getche();
return 0;
}
Compare line 17 and line 40. The function is expecting a string parameter, but you provide none.

On a random note, "void means it is not going to return anything." :|

Edit:
Your exampleFunction(string) has a return type of int. You must return an int, like you return 0 for main, or change its return type to void since you don't seem to need it to return an int.
Last edited on
Topic archived. No new replies allowed.