Function that takes two arguments actually does not?

Hi there everyone. I'm still pretty new to the way classes work and cross-file interaction in Visual C++, and I've been getting an error saying "ConGui::gotoxy: function does not take two arguments" even though I specifically have it set up to take two arguments. Here is the code for the three files that may be effecting this:

filestuph.cpp (Main operating file)
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
#include <windows.h>
#include <conio.h>
#include <stdio.h>
#include "drawmenu.h"
#include "congui.h"

int main()
{
	ConGui congui;
	int i, xpos = 10, ypos[MaxNo_Menu] = { 3, 6, 9, 12, 15 };
	bool running = true;
	MenuDrawing menudrawing; //Create an object from the MenuDrawing class?
	menudrawing.drawmenu();
	// make menu available to choose
	//i=0;
	while(running)
	{

	//*********TROUBLE LINE:***********
congui.gotoxy(xpos, ypos[i]);

		textattr(14 | 2*16);
		cprintf("%s",menu_list[i] );

		/* note : 72 -> UP button
			75 -> RIGHT button
            77 -> LEFT button
            80 -> DOWN button
		*/
...
...
...
}
}

(I have truncated the rest of it, since the rest was just unnecessary information.)

congui.h
1
2
3
4
5
6
#define MaxNo_Menu 5

class ConGui {
public:
	int gotoxy();
};


congui.cpp
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
#include "congui.h"

HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);

using namespace System;

int gotoxy(int x,int y)
{
	if(y>Console::WindowHeight)
	{
		SetConsoleTextAttribute(con, FOREGROUND_RED);
		COORD Coord;
		Coord.X=0;
		Coord.Y=0;
		printf("ERROR: Height value is out of range! Specified: ",y," Maximum: ",Console::WindowHeight);
		return -1;
	}
	COORD Coord;
	Coord.X=x;
	Coord.Y=y;	
	
	SetConsoleCursorPosition(con,Coord);
	return 0;
}

void textattr(int color)
{
	SetConsoleTextAttribute(con, color);
}


Well, that's all. I hope someone can help :(
You declared your function in your header to take no arguments. See?
int gotoxy();

-Albatross
Oh, so I just add the arguments to that? I thought redefining it in the cpp file would have added those arguments.
Last edited on
Yes. Just add the arguments to the header file.

The function in your .cpp file does not redefine it. Whatever you write in the header files (function declarations) must be identical in the .cpp file.
Ok, thank you.

I'm having another problem here. I'm getting an error "cannot convert const char * to char" after I've defined a variable, and then when I want to fill it. Here's the appropriate code:

globals.h
1
2
3
#define MaxNo_Menu 5
extern int xpos, ypos[MaxNo_Menu];
extern char *menu_list[MaxNo_Menu];


filestuph.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <windows.h>
#include <conio.h>
#include <stdio.h>
#include "drawmenu.h"
#include "congui.h"
#include "globals.h"

void dobeep()
{
	Beep(500, 1000);
}

int main()
{
	//Set define variables
	xpos = 10;
	ypos[MaxNo_Menu] = ( 3, 6, 9, 12, 15 );
	*menu_list[MaxNo_Menu] = ("BEEP", "EDIT", "DELETE", "SAVE", "EXIT");
...
...
...


If anyone could help, that would be great.

EDIT: And the same problem occurs when I remove the pointer from both variables.
Last edited on
Topic archived. No new replies allowed.