Too many arguements in function call HELP

I don't seem to know why I keep getting this too many arguments in function call error, and no matter what I've tried to do has changed it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include "ASCIIRenderer.cpp"
using namespace std;

int main()
{
	bool quit = false;
	ASCIIRenderer renderer;
	unsigned short int pass = 0;
	while (!quit)
	{
		renderer.FillScreen(0, pass++);
		renderer.RenderBufferToConsole();
		Sleep(50);
	}
	return 0;
}

1
2
3
4
#include <windows.h>

const int SCREEN_WIDTH = 80;
const int SCREEN_HEIGHT = 25;

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "ASCIIRenderer.h"

class ASCIIRenderer
{

    private:

		CHAR_INFO m_ScreenBuffer[SCREEN_WIDTH * SCREEN_HEIGHT];
		HANDLE m_hConsole;

		void GetConsoleHandle()
		{
			m_hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
		}

		void SetScreenSize()
		{
			COORD MaxWindowSize = GetLargestConsoleWindowSize(m_hConsole);
			int targetWidth = min(MaxWindowSize.X, SCREEN_WIDTH);
			int targetHeight = min(MaxWindowSize.Y, SCREEN_HEIGHT);
			SMALL_RECT rect = { 0, 0, targetWidth - 1, targetHeight - 1 };
			COORD coord = { targetWidth, targetHeight };
			bool bufferSizeSet = SetConsoleScreenBufferSize(m_hConsole, coord);
			bool windowInfoSet = SetConsoleWindowInfo(m_hConsole, TRUE, &rect);
		}

		void InitialiseScreenBuffer()
		{
			CHAR asciiChar = 0;
			WORD attributes = 15;

			for (int i = 0; i < SCREEN_WIDTH; i++)
			{
				for (int j = 0; j < SCREEN_HEIGHT; j++)
				{
					m_ScreenBuffer[SCREEN_WIDTH * j + i].Char.AsciiChar = asciiChar;
					m_ScreenBuffer[SCREEN_WIDTH * j + i].Attributes = attributes;
				}
			}

		}

    public:

		ASCIIRenderer();
		~ASCIIRenderer();

		void Initialise()
		{
			GetConsoleHandle();
			SetScreenSize();
			InitialiseScreenBuffer();
			SetConsoleTitle("4107COMP PONGOUT");
		}

		void RenderBufferToConsole()
		{
			COORD coord = { SCREEN_WIDTH, SCREEN_HEIGHT };
			COORD coord2 = { 0, 0 };
			SMALL_RECT write = { 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 };// Region to write to
			WriteConsoleOutput(m_hConsole, (const CHAR_INFO *)(&m_ScreenBuffer), coord, coord2, &write);
		}

		void ClearScreen()
		{
			InitialiseScreenBuffer();
		}

		void FillScreen()
		{
			InitialiseScreenBuffer();
			{
				CHAR asciiChar = 0;
				WORD attributes = 15;
			}
		}

};
ASCIIRenderer::ASCIIRenderer()
{
	Initialise();
}
ASCIIRenderer::~ASCIIRenderer()
{

}
closed account (48T7M4Gy)
Post the whole error message please. Essentially, you have to match exactly the parameters - number, type and order - against the function header/prototype.
1> Main.cpp
1>i:\assignments\game programming\assignment 2 of 2 ascii\assignment 2 of 2 ascii\asciirenderer.cpp(23): warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
1>i:\assignments\game programming\assignment 2 of 2 ascii\assignment 2 of 2 ascii\asciirenderer.cpp(24): warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
1>i:\assignments\game programming\assignment 2 of 2 ascii\assignment 2 of 2 ascii\asciirenderer.cpp(74): warning C4101: 'attributes' : unreferenced local variable
1>i:\assignments\game programming\assignment 2 of 2 ascii\assignment 2 of 2 ascii\asciirenderer.cpp(73): warning C4101: 'asciiChar' : unreferenced local variable
1>i:\assignments\game programming\assignment 2 of 2 ascii\assignment 2 of 2 ascii\main.cpp(12): error C2660: 'ASCIIRenderer::FillScreen' : function does not take 2 arguments
1> ASCIIRenderer.cpp
1>i:\assignments\game programming\assignment 2 of 2 ascii\assignment 2 of 2 ascii\asciirenderer.cpp(23): warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
1>i:\assignments\game programming\assignment 2 of 2 ascii\assignment 2 of 2 ascii\asciirenderer.cpp(24): warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
1>i:\assignments\game programming\assignment 2 of 2 ascii\assignment 2 of 2 ascii\asciirenderer.cpp(74): warning C4101: 'attributes' : unreferenced local variable
1>i:\assignments\game programming\assignment 2 of 2 ascii\assignment 2 of 2 ascii\asciirenderer.cpp(73): warning C4101: 'asciiChar' : unreferenced local variable
closed account (48T7M4Gy)
Ignoring warnings, which I am sure someone will come along and give you advice on, the error is in your use of the FillScreen function.

Your line 12 in the first section shows 2 parameters being passed while the corresponding method in your class has none. That's the error! They have to match or you have to overload the method, ie have another version that takes 2 parameters.
Last edited on
Topic archived. No new replies allowed.