Help with errors for multiple inheritance

Hi, I have got following errors and do not know where to
fix the error.

//lab4.cpp//
Error 1-2 error C2661: 'BillingTN::BillingTN' : no overloaded function takes 4 arguments (Line25-26)
Error 3-4 IntelliSense: no instance of constructor "BillingTN::BillingTN" matches the argument list
argument types are: (const char [4], const char [4], const char [5], const char [10] (Line23-24)


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
//lab4.cpp//
#include "TelephoneNumber.h"
#include "WorkingTN.h"
#include "BillingTN.h"


using namespace std;

ostream &operator << (ostream &Out, TelephoneNumber &TN)
{
	TN.PrintToStream(Out);
	return Out;
}

void main()
{
	//Declaring Telephone Objects
	TelephoneNumber YourNumber;
	TelephoneNumber Paul("719", "590", "6768");
	TelephoneNumber Bob("719", "590", "6729");
	WorkingTN CSStaff1("719", "590", "6732", "Book Store");
	WorkingTN CSStaff2("212", "371", "6940", "Borland C++ Guru");
	WorkingTN CSStaff3("405", "612", "3433", "Visual C++ Expert");
	BillingTN CSDept("719", "590", "6850", "Dean of CS");
	BillingTN Library("719", "598", "6708", "Librarian");
	BillingTN Reception("719", "598", "0200", "Receptionist", 35);

	cout << "Testing the overloaded << operator with the virtual" << "PrintToStream() \n";
	cout << "\nThe Telephone numbers are: \n";
	cout << YourNumber << endl;
	cout << Paul << endl;
	cout << Bob << endl;
	cout << "\nThe working Telephone numbers are: \n";
	cout << CSStaff1 << endl;
	cout << CSStaff2 << endl;
	cout << CSStaff3 << endl;
	cout << "\nThe Billing Telephones numbers are: \n";
	cout << CSDept << endl;
	cout << Library << endl;
	cout << Reception << endl;

	cout << "End Tests of Telephone hierachy!" << endl;
}


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
//TelephoneNumber.h//
//class TelephoneNumber declaration
#ifndef TELEPHONENUMBER_H
#define TELEPHONENUMBER_H

#include <string>
#include <iostream>
using namespace std;

class TelephoneNumber
{
public:
	TelephoneNumber();
	TelephoneNumber(const string &inNPA, const string &inNXX, const string &inLine);
	~TelephoneNumber() { cout << "In TelephoneNumber default destructor\n"; }

	//Setters and Getters for string members
	void SetNPA(string &NewNPA);
	string GetNPA() const;
	void SetNXX(string &NewNXX);
	string GetNXX() const;
	void SetLine(string &Newline);
	string GetLine() const;

	//
	virtual void PrintToStream(ostream &Out);

private:
	string NPA;
	string NXX;
	string Line;
};

#endif


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

TelephoneNumber::TelephoneNumber()
{
	do
	{
		cout << "Enter 3-digit Area code: ";
		getline(cin, NPA);
	} while (NPA.length() != 3);

	do
	{
		cout << "Enter 3-digit Prefix: ";
		getline(cin, NXX);
	} while (NXX.length() != 3);

	do
	{
		cout << "Enter 4-digit Line: ";
		getline(cin, Line);
	} while (Line.length() != 4);

	cout << "In TelephoneNumber default constructor\n";

}

TelephoneNumber::TelephoneNumber(const string &inNPA, const string &inNXX, const string &inLine)
{
	if (inNPA.length() < 3)
	{
		cout << "NPA parameter too short -- defaulting to 555\n";
		NPA = "555";
	}

	else if (NPA.length() > 3)
	{
		cout << "NPA parameter too long -- truncating to 3 digits\n";
		NPA = inNPA.substr(0, 3);
	}
	else
	{
		NPA = inNPA;
	}

	if (inNXX.length() < 3)
	{
		cout << "NPA parameter too short -- defaulting to 555\n";
		NPA = "555";
	}

	else if (NXX.length() > 3)
	{
		cout << "NXX parameter too long -- truncating to 3 digits\n";
		NPA = inNXX.substr(0, 3);
	}
	else
	{
		NXX = inNXX;
	}
	cout << "In 3-parameter TelephoneNumber constructor\n";

	if (inLine.length() < 4)
	{
		cout << "NPA parameter too short -- defaulting to 555\n";
		Line = "5555";
	}

	else if (Line.length() > 4)
	{
		cout << "NPA parameter too long -- truncating to 3 digits\n";
		Line = inLine.substr(0, 4);
	}
	else
	{
		Line = inLine;
	}



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//WorkingTN.h//
#ifndef WORKINGTN_H
#define WORKINGTN_H

#include "TelephoneNumber.h"

class WorkingTN : public TelephoneNumber
{
public:
	WorkingTN();
	WorkingTN(const string &inNPA, const string &inNXX, const string &inLine, const string &inCustomerName);
	~WorkingTN() { cout << "In WorkingTN destructor\n"; }
	void SetCustomerName(const string &newCustomerName);
	string GetCustomerName() const;
	virtual void PrintToStream(ostream &Out);

protected:
	string CustomerName;
};

#endif


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

WorkingTN::WorkingTN() :TelephoneNumber()
{
	cout << "Enter customer name: ";
	getline(cin, CustomerName);

	cout << "In WorkingTN default constructor\n";
}

WorkingTN::WorkingTN(const string &inNPA, const string &inNXX, const string &inLine, const string &inCustomerName) : TelephoneNumber(inNPA, inNXX, inLine)
{
	CustomerName = inCustomerName;

	cout << "In WorkingTN 4-parameter constructor\n";
}

void WorkingTN::SetCustomerName(const string &newCustomerName)
{
	CustomerName = newCustomerName;
}

string WorkingTN::GetCustomerName() const
{
	return CustomerName;
}

void WorkingTN::PrintToStream(ostream &Out)
{
	TelephoneNumber::PrintToStream(Out);
	cout << "\nCustomer:\t  " << CustomerName;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//BillingTN.h//
#ifndef BILLINGTN_h
#define BILLINGTN_h

#include "WorkingTN.h"

class BillingTN : public WorkingTN
{
public:
	BillingTN();
	BillingTN(const string &inNPA, const string &inNXX, const string &inLine, const string &inCustomerName, int inNumWorkingTNs);
	~BillingTN() { cout << "In BillingTN destructor\n"; }
	void setWorkingTNs(int NumWorkingTNs);
	int getWorkingTNs() const;
	virtual void PrintToStream(ostream &Out);

protected:
	int NumWorkingTNs;
};

#endif


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

BillingTN::BillingTN() : WorkingTN()
{

	cout << "How many working lines? ";
	cin >> NumWorkingTNs;

	cout << "In BillingTN default constructor\n";
}

BillingTN::BillingTN(const string &inNPA, const string &inNXX, const string &inLine, const string &inCustomerName, int inNumWorkingTNs) : WorkingTN(inNPA, inNXX, inLine, inCustomerName)
{
	NumWorkingTNs = inNumWorkingTNs;

	cout << "In BillingTN 5-parameter constructor\n";
}

void BillingTN::setWorkingTNs(int inNumWorkingTNs)
{
	NumWorkingTNs = inNumWorkingTNs;
}

int BillingTN::getWorkingTNs() const
{
	return NumWorkingTNs;
}

void BillingTN::PrintToStream(ostream &Out)
{
	WorkingTN::PrintToStream(Out);
	cout << "\nNumber of Working Lines: " << NumWorkingTNs;
}


You are trying to construct a BillingTN object by passing 4 string arguments to the constructor but BillingTN has no such constructor. It has one constructor that takes 0 elements and one that takes 5.
Topic archived. No new replies allowed.