constructor error

Hello im getting an error on line 12 of my main.cpp file but the error I get is no default contructor exists for CustomerData

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <string>
#include "CustomerData.h"
#include "PersonData.h"
using namespace std;

void dataDisplay(CustomerData c);

int main()

{
	CustomerData data;(101, true, "Daniel", "Dominick", "28791");
	cout << "Data:";
	dataDisplay(data);

}

void dataDisplay(CustomerData c)
{
	cout << "Last Name: " << c.getlastname() << endl;
	cout << "First Name: " << c.getfirstname() << endl;
	cout << "Zip: " << c.getzip() << endl;
}
This is my CustomerData.cpp if that helps

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

void CustomerData::setCustomerNumber(int cn)
{
	customerNumber = cn;
}

void CustomerData::setShareData(bool sd)
{
	shareData = sd;
}

int CustomerData::getCustomerNumber()
{
	return customerNumber;
}

bool CustomerData::getShareData()
{
	return shareData;
}

CustomerData::CustomerData(int cn, bool sd, string lname, string fname, string Zip) :PersonData(lname, fname, Zip)
{
	customerNumber = 0;
	shareData = false;
};
Last edited on
Hi

You have an extra semicolon on line 12 :+)

In that ctr, you ignore the data in the parameters cn, sd. Perhaps lines 28 & 29 should be in the definition of the class in CustomerData.h, they look like default values ?
Topic archived. No new replies allowed.