overloading in classes

Is it possible to overload a function in a class ? if then how to do it?

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

Line::Line()
{
}
void Line::create(Point n, Point m)
{
	Line::P1=n;
	Line::P2=m;

	Line::calcLength(); // Calculate distance after assigning values for points
}
void Line::display()
{
	cout<<"Point 1: ";
	Line::P1.display();
	cout <<"\nPoint 2: ";
	Line::P2.display();
	cout<<"\nLength of the line: ";
	cout <<Line::length <<endl;
}
void Line::calcLength()
{
	double lengthX = Line::P2.getX() - Line::P1.getX();
	double lengthY = Line::P2.getY() - Line::P1.getY();
	Line::length = sqrt( (lengthX * lengthX) + (lengthY * lengthY));
}

void Line::create(double x1,double y1, double x2, double y2);
{
	Line::P1.setX(x1);
	Line::P1.setY(y1);
	Line::P2.setX(x2);
	Line::P2.setY(y2);

	cout <<x1;
}


and I'm getting an errors saying :

1>------ Build started: Project: CalculatePerimeter, Configuration: Debug Win32 ------
1>Compiling...
1>Line.cpp
1>c:\users\toshiba\documents\visual studio 2008\projects\iit 2nd semester\calculateperimeter\calculateperimeter\line.cpp(33) : error C2761: 'create' : member function redeclaration not allowed
1>c:\users\toshiba\documents\visual studio 2008\projects\iit 2nd semester\calculateperimeter\calculateperimeter\line.cpp(34) : error C2447: '{' : missing function header (old-style formal list?)
1>Generating Code...
1>Compiling...
1>calulatePerimeter.cpp
1>Generating Code...
1>Build log was saved at "file://c:\Users\TOSHIBA\Documents\Visual Studio 2008\Projects\IIT 2nd Semester\CalculatePerimeter\CalculatePerimeter\Debug\BuildLog.htm"
1>CalculatePerimeter - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


There's a ; on line 33, which makes it a declaration instead of definition.
Topic archived. No new replies allowed.