Easy Class Problem i'm having any tips will be very appreciated

so i'm new to C++ programming and i'm just trying to test this really easy class but it's giving me what i think to be some bunk error, any tips would be nice at what it's getting at.
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
#include "utility.h"
#include "filer.h"



void filer::makefile(int n, int range, bool truly_random, string file_name)
{	

	int c = 0;
	
	// I/O for max numbers
	cout << "How many numbers would you like to be put in this file?" << endl;
	cin >> n;

	// I/O for range of numbers
	cout << "What would you like the ceiling number to be? (the floor number is pre-set at 0)" << endl;
	cin >> range;

	// I/O for file name
	cout << "What would you like the name of your file to be?" << endl;
	cin >> file_name;

	// I/O for decision on truly random or psuedorandom
	cout << "Would you like your numbers to be Psuedorandom or Truly random?" << endl;
	cout << "If you would like Psuedorandom press '1' if Truly random press '2'" << endl;
	cin >> c;

	

	
}// end filer.makefile 


then when i try and run this main, i'm getting these three errors:
error C2144: syntax error : 'int' should be preceded by ')'
error C2660: 'filer::makefile' : function does not take 0 arguments
error C2059: syntax error : ')'

which are all coming from my main, which can be seen below
1
2
3
4
5
6
7
8
9
10
#include "utility.h"
#include "filer.h"
#include "filer.cpp"

int main()
{
	filer run;
	run.makefile(int n, int range, bool truly_random, string file_name);

} // end main 


my header files are pre-given files by our professor which we aren't suppose to touch
1) Dont' include cpp files. You should only be including filer.h

2) when you call a function, you need to supply values for all the arguments. You are just repeating the argument list which is nonsense. You need to tell the computer what values to use for those arguments.

1
2
3
//run.makefile(int n, int range, bool truly_random, string file_name);  // <- bad

run.makefile(5,6,false,"example"); // <- good 


Here, I'm telling the makefile function to use 5 for 'n', 6 for 'range', false for 'truly_random', and "example" for 'file_name'. You'll need to come up with different values that make the function do whatever you want it to do (I just picked values at random).

That's how you call functions.
oh, okay! sweet!

so, what is the case if the user inputs the values for those variables in the makefile function?
Get the input from the user, put it in your own variables in main, then pass those variables to the function:

1
2
3
4
5
int whatever;

// get 'whatever' from the user here

run.makefile( whatever, //... 
So, you are saying all my I/O's in the other cpp file should go in my main!

thank you very much :)
Yeah. Actually I hadn't looked at what the makefile function actually did. =x

Since you said your teacher provided the prototype, that tells me he wants you to pass the stuff to the function. So yeah, your function should not be getting that info from the user. It should just be using whatever was passed to it.
Topic archived. No new replies allowed.