Now I'm totally confused. I posted this code in another topic earlier and got help with that problem but now I have another that seems even stranger to me. This is the first error (for reference the rest of the errors are after the code:
1 2 3 4
|
person.cpp: In constructor ‘Person::Person(QString)’:
person.cpp:12:16: error: no matching function for call to ‘Position::Position()’
: m_Name(name)
|
Here's the code. As you can see the line pointed to in the error - person.cpp:12:16 - is not "‘Position::Position()’
: m_Name(name).
person.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 30 31
|
// Person.cpp
// pn Mar03-2014
#include <QString>
#include <QTextStream>
//#include "position.h"
#include "person.h"
//#include "employer.h"
Person::Person(QString name)
: m_Name(name)
{
}
QString Person::toString()
{
QString buffer;
QTextStream bufStr(&buffer);
bufStr << "Person Name: " << m_Name << endl;
//buffer = "Person Name: " + m_Name + "\n";
return buffer;
}
void Person::setPosition(Employer newC, Position newP)
{
m_Position = newP;
m_Employer = newC;
}
|
person.h =============================================
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
|
#ifndef _PERSON_H_
#define _PERSON_H_
#include <QString>
#include "employer.h"
#include "position.h"
//class Employer;
//class Position;
class Person
{
public:
Person(QString name);
void setPosition(Employer newC, Position newP);
QString toString();
private:
QString m_Name;
bool m_Employed;
Position m_Position;
Employer m_Employer;
};
#endif
|
position.h ===========================================
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#ifndef _POSITION_H_
#define _POSITION_H_
#include <QString>
//class Employer;
//class Person;
class Position
{
public:
Position(QString name, QString description);
QString toString();
private:
QString m_Name;
QString m_Description;
};
#endif
|
position.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
|
// Position.cpp
// pn Mar03-2014
#include <QString>
#include <QTextStream>
#include "position.h"
//#include "person.h"
//#include "employer.h"
Position::Position(QString name, QString description)
: m_Name(name), m_Description(description)
{
}
QString Position::toString()
{
QString buffer;
QTextStream bufStr(&buffer);
bufStr << "Position Name: " << m_Name << endl;
bufStr << "Position Description: " << m_Description << endl;
//buffer = "Position Name: " + m_Name + "\n";
//return buffer.toStdString();
return buffer;
}
|
Employer.h ===========================================
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
|
// employer.h
// pn mar08-2014
#ifndef _EMPLOYER_H_
#define _EMPLOYER_H_
#include <QString>
//using namespace std;
//class Person;
//class Position;
class Employer
{
public:
Employer(QString name, QString market);
// bool hire(Person& newHire, Position pos);
QString toString();
private:
QString m_Name;
QString m_Market;
};
#endif
|
emplyer.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
|
// employer.cpp
// pn Mar05-2014
#include <QString>
#include <QTextStream>
#include "position.h"
#include "person.h"
#include "employer.h"
Employer::Employer(QString name, QString market)
: m_Name(name), m_Market(market) {}
QString Employer::toString()
{
QString buffer;
QTextStream bufStr(&buffer);
bufStr << "Employer Name: " << m_Name << endl;
bufStr << "Employer Market: " << m_Market << endl;
//buffer = "Person Name: " + m_Name + "\n";
//return buffer.toStdString();
return buffer; //QString
}
/*
bool Employer::hire(Person& newHire, Position pos)
{
return true;
}
*/
|
work.cpp (main) ======================================
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
|
// work.cpp
// pn mar05-2014
#include <QString>
#include <QTextStream>
#include <iostream>
#include "person.h"
#include "employer.h"
#include "position.h"
using namespace std;
int main()
{
QString name;
QString company;
QString location;
Person phil("Bozo");
Employer sst("SST", "Speed");
Position posture("Standing", "Not Sitting");
//QTextStream qts();
//qts << phil.toString();
name = phil.toString();
cout << name.toStdString();
company = sst.toString();
cout << company.toStdString();
location = posture.toString();
cout << location.toStdString();
return 0;
}
|
rest of errors =======================================
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
|
person.cpp:12:16: note: candidates are:
In file included from person.h:6:0,
from person.cpp:7:
position.h:14:5: note: Position::Position(QString, QString)
Position(QString name, QString description);
^
position.h:14:5: note: candidate expects 2 arguments, 0 provided
position.h:9:7: note: Position::Position(const Position&)
class Position
^
position.h:9:7: note: candidate expects 1 argument, 0 provided
person.cpp:12:16: error: no matching function for call to ‘Employer::Employer()’
: m_Name(name)
^
person.cpp:12:16: note: candidates are:
In file included from person.h:5:0,
from person.cpp:7:
employer.h:19:5: note: Employer::Employer(QString, QString)
Employer(QString name, QString market);
^
employer.h:19:5: note: candidate expects 2 arguments, 0 provided
employer.h:14:7: note: Employer::Employer(const Employer&)
class Employer
^
employer.h:14:7: note: candidate expects 1 argument, 0 provided
make: *** [person.o] Error 1
|
======================================================
TIA for any pointers.