header files and classes.

Having a hard time with the syntax. I have a complex problem, but basically I cant get the syntax right. I keep getting the following errors,

pa8.cpp:11:23: error: no matching function for call to ‘Coordinate::printCoordinate()’
Coordinate.h:9:10: note: void Coordinate::printCoordinate(int, int, int)
Coordinate.h:9:10: note: candidate expects 3 arguments, 0 provided

I have to break this file into three files, here are the three

1
2
3
4
5
6
7
8
9
10
11
12
13
class Coordinate
{
    public:
    Coordinate (int x, int y, int z)
    {	
    printCoordinate(x, y, z);
    }
    
    void printCoordinate(int x, int y, int z)
    {
		std::cout<<x<<y<<z;
	}
};


1
2
3
4
5
6
7
8
9
10
11
12
#include "Coordinate.h"


    Coordinate::Coordinate(int x, int y, int z);
    {    
		printCoordinate(x,y,z)
	}
	
	void Coordinate::printCoordinate(int x, int y, int z)
	{
		
	}


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 <iostream>
#include "Coordinate.h"
using namespace std;

int main()
{
    Coordinate a( 1, 7, 0 ); //  , b( 9, 8, 7 ), c;

    a.printCoordinate();
    /*
    cout << " + ";
    b.printCoordinate();
    cout << " = ";
    
    c = a.add( b );
    c.printCoordinate();
    
    cout << '\n';
    a.setCoordinate( 10, 1, 10 );
    b.setCoordinate( 11, 3, 20 );
    a.printCoordinate();
    cout << " - ";
    b.printCoordinate();
    cout << " = ";
    c = a.subtract( b );
    c.printCoordinate();
    cout << endl;
    */
}


The only thing i'm trying to do right now is output the first coordinate to get the syntax. also, im not allowed to change the last code. can someone please point me in the right direction? thank you for you time.
pa8.cpp:11:23: error: no matching function for call to ‘Coordinate::printCoordinate()’
Coordinate.h:9:10: note: void Coordinate::printCoordinate(int, int, int)
Coordinate.h:9:10: note: candidate expects 3 arguments, 0 provided


a.printCoordinate();

Just as the compiler says
candidate expects 3 arguments, 0 provided


I don't see the point of the constructor calling printCoordinate.

Hope all goes well.
Last edited on
Topic archived. No new replies allowed.