SlideShare a Scribd company logo
Getting the following errors:
Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on
line 565
Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on
line 761
I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!!
#include
#include
#include
#include
using namespace std;
enum contactGroupType
{// used in extPersonType
FAMILY,
FRIEND,
BUSINESS,
UNFILLED
};
class addressType
{
private:
string st_address;
string city;
string state;
int zip;
public:
void print(string, string, string, int)const;
void setStreet(string);
string getStreet()const;
void setCity(string);
string getCity()const;
void setState(string);
string getState()const;
void setZip(int);
int getZip()const;
void set(string, string, string, int);// set all address fields
string get()const;// get address as one concatenated string
addressType();
// ~addressType();
};
class personType
{
private:
string firstName;
string lastName;
public:
void print()const;
void setName(string first, string last);
string getFirstName()const;
string getLastName()const;
string get()const;// return First Last names concatenated
personType & operator=(const personType &);
personType(string, string);
personType();
};
class dateType
{
private:
int dMonth;
int dDay;
int dYear;
public:
void setDate(int month, int day, int year);
int getDay()const;
int getMonth()const;
int getYear()const;
void print()const;
string get()const;// return string representation as DD/MM/YYYY
dateType & operator=(const dateType & d);
dateType(int, int, int);
dateType();
};
class extPersonType :public personType {
private:
addressType address;// added members
dateType birthday;
contactGroupType group;
string phone;
public:
// methods
void setPhone(string);
string getPhone()const;
void setGroup(contactGroupType);
contactGroupType getGroup()const;
void setBirthday(int, int, int);
dateType getBirthday()const;
void print();
string get()const;// return string representation of ext person type
extPersonType & operator=(const extPersonType & p);
string groupToString(contactGroupType)const;
contactGroupType stringToGroup(string)const;
// constructors
extPersonType();
extPersonType(string first, string last);
};
// because we have no arrayListType, we are using our own
// implementation with a small subset of functions
class arrayListType
{
extPersonType array[500];
int size;
public:
arrayListType();
extPersonType & operator[](int i);
void removeLast();// remove last element
void add(const extPersonType &);// add new element
int getSize()const;// get array size
};
class addressBookType :public arrayListType
{
private:
static const char FS = 't';// field separator in file (TAB char)
int current;// current position
string fileName;// filename
fstream fileStream;// file as fstream
/* filiters */
contactGroupType fltGroup;
string fltFromLast, fltToLast;
dateType fltFromDate, fltTiDate;
/* flags for effective filters */
bool fltStatus, fltLast, fltDateRange, fltDate;
/* field numbering in the file */
static const int _first = 0;
static const int _last = 1;
static const int _street = 2;
static const int _city = 3;
static const int _state = 4;
static const int _phone = 5;
static const int _zip = 6;
static const int _year = 7;
static const int _month = 8;
static const int _day = 9;
static const int _group = 10;
static const int _end = _group;
public:
addressBookType();
bool readFile(string);// read file into addressBook array
bool writeFile(string);// pass filename, write to file
void reset();// reset 'current' position
extPersonType * getNext();// allows to navigate in forward direction
/* by group name */
void setFilterStatus(contactGroupType);
/* by last name */
void setFilterLastname(string from, string to);// define range
/* by birthday */
void setFilterBirthday(dateType from, dateType to);
/* clear all filters */
void clearFilters();
void print(int i);// print personal data of [i] person
};
// Main program
int main()
{
return 0;
}
/*****************implementation of print & set function*****/
// constructor with parameters
addressType::addressType()
{
st_address = "";
city = "";
state = "";
zip = 0;
}
void addressType::set(string addr, string city, string state, int zip)
{
this->st_address = addr;
this->city = city;
this->state = state;
this->zip = zip;
}
void addressType::setStreet(string street)
{
this->st_address = street;
}
string addressType::getStreet()const
{
return this->st_address;
}
void addressType::setCity(string street)
{
this->city = street;
}
string addressType::getState()const
{
return this->state;
}
void addressType::setState(string street)
{
this->st_address = street;
}
void addressType::setZip(int code)
{
this->zip = code;
}
int addressType::getZip()const
{
return this->zip;
}
/* personType implementation */
personType::personType()
{// constructor
this->setName("", "");
}
personType::personType(string first, string last){// constructor
this->setName(first, last);
}
void personType::setName(string first, string last)
{
firstName = first;
lastName = last;
}
string personType::getFirstName()const
{
return firstName;
}
string personType::getLastName()const
{
return lastName;
}
void personType::print()const
{
cout << get() << " ";
}
string personType::get()const
{
return firstName + " " + lastName;
}
personType & personType::operator=(const personType & p)
{
setName(p.getFirstName(), p.getLastName());
return*this;
}
/* Constructor */
dateType::dateType()
{
setDate(1, 1, 1900);
}
dateType::dateType(int d, int m, int y)
{
setDate(d, m, y);
}
int dateType::getDay()const
{
return dDay;
}
int dateType::getMonth()const
{
return dMonth;
}
int dateType::getYear()const
{
return dYear;
}
void dateType::setDate(int d, int m, int y)
{
dDay = d;
dMonth = m;
dYear = y;
}
void dateType::print()const
{
cout << get() << " ";
}
string dateType::get()const
{
string a;
a = dDay;
a += "/";
a += dMonth;
a += "/";
a += dYear;
return a;
}
dateType & dateType::operator=(const dateType & d)
{
this->dDay = d.getDay();
this->dMonth = d.getMonth();
this->dYear = d.getYear();
return*this;
}
/* Implementation of extPersonType */
extPersonType::extPersonType()
{
phone = "";
group = UNFILLED;
birthday.setDate(01, 01, 1900);
}
extPersonType::extPersonType(string first, string last) : personType::personType(first, last)
{
phone = "";
group = UNFILLED;
birthday.setDate(01, 01, 1900);
}
void extPersonType::setBirthday(int d, int m, int y)
{
birthday.setDate(d, m, y);
}
dateType extPersonType::getBirthday()const
{
return birthday;
}
void extPersonType::setGroup(contactGroupType gr)
{
group = gr;
}
contactGroupType extPersonType::getGroup()const
{
return group;
}
void extPersonType::setPhone(string ph)
{
phone = ph;
}
string extPersonType::getPhone()const
{
return phone;
}
// Override parent's 'get()' add phone and birthday
string extPersonType::get()const
{
string result;
result = this->personType::get();
result = result + " " + birthday.get() + " " + phone + " " + groupToString(group);
return result;
}
extPersonType & extPersonType::operator=(const extPersonType & p)
{
// first call superclass' operator=
(personType)*this = (personType)p;
// now assign birthday, phone and category
this->phone = p.getPhone();
this->birthday = p.getBirthday();
this->group = p.getGroup();
return*this;
}
string extPersonType::groupToString(contactGroupType a)const
{
string result;
switch (a)
{
case FAMILY:
result = "FAMILY";
break;
case FRIEND:
result = "FRIEND";
break;
case BUSINESS:
result = "BUSINESS";
break;
case UNFILLED:
result = "";
break;
}
return result;
}
contactGroupType extPersonType::stringToGroup(string a)const
{
contactGroupType result;
if (a.compare("FAMILY") == 0) result = FAMILY;
else if (a.compare("FRIEND") == 0) result = FRIEND;
else if (a.compare("BUSINESS") == 0) result = BUSINESS;
else result = UNFILLED;
return result;
}
arrayListType::arrayListType()
{
size = 0;
}
int arrayListType::getSize()const
{
return size;
}
void arrayListType::removeLast()
{
size--;
}
void arrayListType::add(const extPersonType &p)
{
array[size++] = p;
}
extPersonType & arrayListType::operator[](int i)
{
return array[i];
}
/* addressBookType implementation */
addressBookType::addressBookType() : arrayListType::arrayListType()
{
reset();
clearFilters();
}
void addressBookType::reset()
{
current = 0;
}
void addressBookType::clearFilters()
{
fltStatus = fltDate = fltLast = fltDateRange = false;
}
/* Read array from file, return false on error */
bool addressBookType::readFile(string filename)
{
string line;
string fields[_end + 1];// _last index of the last field
extPersonType p;// temporary 'person' instance
int pos1 = 0, pos2 = 0, index;
fileStream.open(filename.c_str(), ios::in);
reset();// reset 'current' counter
clearFilters();
while (!fileStream.eof()){// read line by line
fileStream >> line;
// fields are in the following order:
// first, last, street, city, state, zip, phone, status, year, month, day
for (index = 0; index <= _end; index++) fields[index] = "";// initialize
pos2 = 0; pos1 = -1;
index = 0;
do
{// read field by field
pos1 = pos2 + 1;// +1 is for field separator
pos2 = line.find(FS, pos1);
fields[index] = line.substr(pos1, pos2 - pos1);// get field from line
index++;
}
while (pos2 >= 0 && index <= _end);
// now fields[] are filled with fields from file
p.setName(fields[_first], fields[_last]);
p.setPhone(fields[_phone]);
p.setGroup(p.stringToGroup(fields[_group]));// convert string to enum
// set birthday
p.getBirthday().setDate(atoi(fields[_month].c_str()),
atoi(fields[_day].c_str()),
atoi(fields[_year].c_str()));
// add 'p' to array
this->add(p);
}
// while () next line from file
fileStream.close();
return true;
}
// Write to file (stub)
bool addressBookType::writeFile(string filename)
{
return true;
}
Solution
Actually while initializing constructors, you should not use :: operator for calling base class
constructor. See my modification below. Remove :: operator for base class.
Ex:
while initializing child class,
Child::Child(): Base(){ /// Here you used Base::Base() which is wrong(for some compilers)
//
}
And also include header files. That's it. Apart from these things, your code is perfectly alright.
=====================================================================
============================
extPersonType::extPersonType(string first, string last) : personType::personType(first, last)
{
phone = "";
group = UNFILLED;
birthday.setDate(01, 01, 1900);
}
Change the above part of the code as below
extPersonType::extPersonType(string first, string last) : personType(first, last)
{
phone = "";
group = UNFILLED;
birthday.setDate(01, 01, 1900);
}
=====================================================================
============================
/* addressBookType implementation */
addressBookType::addressBookType() : arrayListType::arrayListType()
{
reset();
clearFilters();
}
change the above part of the code to
addressBookType::addressBookType() : arrayListType()
{
reset();
clearFilters();
}

More Related Content

PDF
I have the following code and I need to know why I am receiving the .pdf
DOCX
DS Code (CWH).docx
PDF
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
PDF
In this lab, we will write an application to store a deck of cards i.pdf
PPTX
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
PDF
So here is the code from the previous assignment that we need to ext.pdf
PDF
maincpp Build and procees a sorted linked list of Patie.pdf
PPT
Overloading
I have the following code and I need to know why I am receiving the .pdf
DS Code (CWH).docx
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
In this lab, we will write an application to store a deck of cards i.pdf
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
So here is the code from the previous assignment that we need to ext.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
Overloading

Similar to Getting the following errorsError 1 error C2436 {ctor} mem.pdf (20)

PDF
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
PDF
Use the code below from the previous assignment that we need to exte.pdf
PDF
My question is pretty simple, I just want to know how to call my ope.pdf
PDF
could you implement this function please, im having issues with it..pdf
PDF
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PPT
Antlr V3
PDF
please help with java questionsJAVA CODEplease check my code and.pdf
PDF
Help with the following code1. Rewrite to be contained in a vecto.pdf
PDF
Program of sorting using shell sort #include stdio.h #de.pdf
PDF
I have to write a polynomial class linked list program and i do not .pdf
DOCX
There are a number of errors in the following program- All errors are.docx
PDF
for initializer_list include ltinitializer_listgt .pdf
PDF
#include iostream #include cstring #include vector #i.pdf
PDF
Что нам готовит грядущий C#7?
PDF
Principals of Programming in CModule -5.pdf
DOCX
IN C LANGUAGE- I've been trying to finish this program for the last fe.docx
PDF
c programming
PPT
Lecture5
DOCX
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
PDF
C programming.   For this code I only need to add a function so th.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Use the code below from the previous assignment that we need to exte.pdf
My question is pretty simple, I just want to know how to call my ope.pdf
could you implement this function please, im having issues with it..pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
Antlr V3
please help with java questionsJAVA CODEplease check my code and.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
I have to write a polynomial class linked list program and i do not .pdf
There are a number of errors in the following program- All errors are.docx
for initializer_list include ltinitializer_listgt .pdf
#include iostream #include cstring #include vector #i.pdf
Что нам готовит грядущий C#7?
Principals of Programming in CModule -5.pdf
IN C LANGUAGE- I've been trying to finish this program for the last fe.docx
c programming
Lecture5
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
C programming.   For this code I only need to add a function so th.pdf

More from herminaherman (20)

PDF
Write an equation for the height of the point P above the ground as .pdf
PDF
Wild-type (WT) mice are irradiated, destroying all of their bone marr.pdf
PDF
Which of the following is considered to be a distributed denial of s.pdf
PDF
Which of the folllowing statements about the solubility of 1- propan.pdf
PDF
What type of mutation that impacts splicing is a significant contrib.pdf
PDF
What data indicate that all three germ layers are specified in the b.pdf
PDF
Unlike RNA, DNA containsA. adenine.B. uracil.C. phosphate grou.pdf
PDF
Use provided HTML file.Create JavaScript file to validate user i.pdf
PDF
Two four-sided dice are rolled. One die has the letters A through D..pdf
PDF
The job of a CODEC (CoderDecoder) is to Convert an analog voice si.pdf
PDF
Question 4 Constructive retirement is when A. P buys Ss common stoc.pdf
PDF
Private and Public Health are working together through many program .pdf
PDF
Name the two standards that are supported by major DBMSs for distrib.pdf
PDF
Material Manufacturing Name 3 ways that the properties of thermosett.pdf
PDF
Mean can be computed for variables with ordinal-level measurements..pdf
PDF
Let u_1, u_2 be finite dimensional subspaces of a vector space V. Sho.pdf
PDF
IV. Which compound would have the higher water solubility, tetrahydro.pdf
PDF
Interseting discussion topic,want to chime inDescribe a symbol .pdf
PDF
IN JAVA Write a program to create a binary data file named RandomInt.pdf
PDF
I wanna add the shape creator like rectangular , square , circle etc.pdf
Write an equation for the height of the point P above the ground as .pdf
Wild-type (WT) mice are irradiated, destroying all of their bone marr.pdf
Which of the following is considered to be a distributed denial of s.pdf
Which of the folllowing statements about the solubility of 1- propan.pdf
What type of mutation that impacts splicing is a significant contrib.pdf
What data indicate that all three germ layers are specified in the b.pdf
Unlike RNA, DNA containsA. adenine.B. uracil.C. phosphate grou.pdf
Use provided HTML file.Create JavaScript file to validate user i.pdf
Two four-sided dice are rolled. One die has the letters A through D..pdf
The job of a CODEC (CoderDecoder) is to Convert an analog voice si.pdf
Question 4 Constructive retirement is when A. P buys Ss common stoc.pdf
Private and Public Health are working together through many program .pdf
Name the two standards that are supported by major DBMSs for distrib.pdf
Material Manufacturing Name 3 ways that the properties of thermosett.pdf
Mean can be computed for variables with ordinal-level measurements..pdf
Let u_1, u_2 be finite dimensional subspaces of a vector space V. Sho.pdf
IV. Which compound would have the higher water solubility, tetrahydro.pdf
Interseting discussion topic,want to chime inDescribe a symbol .pdf
IN JAVA Write a program to create a binary data file named RandomInt.pdf
I wanna add the shape creator like rectangular , square , circle etc.pdf

Recently uploaded (20)

PPTX
Cell Structure & Organelles in detailed.
PPTX
Institutional Correction lecture only . . .
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
master seminar digital applications in india
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Sports Quiz easy sports quiz sports quiz
PDF
RMMM.pdf make it easy to upload and study
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Insiders guide to clinical Medicine.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
01-Introduction-to-Information-Management.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Cell Structure & Organelles in detailed.
Institutional Correction lecture only . . .
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
master seminar digital applications in india
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Sports Quiz easy sports quiz sports quiz
RMMM.pdf make it easy to upload and study
Final Presentation General Medicine 03-08-2024.pptx
Complications of Minimal Access Surgery at WLH
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Abdominal Access Techniques with Prof. Dr. R K Mishra
Module 4: Burden of Disease Tutorial Slides S2 2025
Insiders guide to clinical Medicine.pdf
Microbial disease of the cardiovascular and lymphatic systems
01-Introduction-to-Information-Management.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial diseases, their pathogenesis and prophylaxis
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
human mycosis Human fungal infections are called human mycosis..pptx
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES

Getting the following errorsError 1 error C2436 {ctor} mem.pdf

  • 1. Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 565 Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 761 I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!! #include #include #include #include using namespace std; enum contactGroupType {// used in extPersonType FAMILY, FRIEND, BUSINESS, UNFILLED }; class addressType { private: string st_address; string city; string state; int zip; public: void print(string, string, string, int)const; void setStreet(string); string getStreet()const; void setCity(string); string getCity()const; void setState(string); string getState()const; void setZip(int); int getZip()const;
  • 2. void set(string, string, string, int);// set all address fields string get()const;// get address as one concatenated string addressType(); // ~addressType(); }; class personType { private: string firstName; string lastName; public: void print()const; void setName(string first, string last); string getFirstName()const; string getLastName()const; string get()const;// return First Last names concatenated personType & operator=(const personType &); personType(string, string); personType(); }; class dateType { private: int dMonth; int dDay; int dYear; public: void setDate(int month, int day, int year); int getDay()const; int getMonth()const; int getYear()const; void print()const; string get()const;// return string representation as DD/MM/YYYY dateType & operator=(const dateType & d); dateType(int, int, int); dateType();
  • 3. }; class extPersonType :public personType { private: addressType address;// added members dateType birthday; contactGroupType group; string phone; public: // methods void setPhone(string); string getPhone()const; void setGroup(contactGroupType); contactGroupType getGroup()const; void setBirthday(int, int, int); dateType getBirthday()const; void print(); string get()const;// return string representation of ext person type extPersonType & operator=(const extPersonType & p); string groupToString(contactGroupType)const; contactGroupType stringToGroup(string)const; // constructors extPersonType(); extPersonType(string first, string last); }; // because we have no arrayListType, we are using our own // implementation with a small subset of functions class arrayListType { extPersonType array[500]; int size; public: arrayListType(); extPersonType & operator[](int i); void removeLast();// remove last element void add(const extPersonType &);// add new element int getSize()const;// get array size
  • 4. }; class addressBookType :public arrayListType { private: static const char FS = 't';// field separator in file (TAB char) int current;// current position string fileName;// filename fstream fileStream;// file as fstream /* filiters */ contactGroupType fltGroup; string fltFromLast, fltToLast; dateType fltFromDate, fltTiDate; /* flags for effective filters */ bool fltStatus, fltLast, fltDateRange, fltDate; /* field numbering in the file */ static const int _first = 0; static const int _last = 1; static const int _street = 2; static const int _city = 3; static const int _state = 4; static const int _phone = 5; static const int _zip = 6; static const int _year = 7; static const int _month = 8; static const int _day = 9; static const int _group = 10; static const int _end = _group; public: addressBookType(); bool readFile(string);// read file into addressBook array bool writeFile(string);// pass filename, write to file void reset();// reset 'current' position extPersonType * getNext();// allows to navigate in forward direction /* by group name */ void setFilterStatus(contactGroupType); /* by last name */
  • 5. void setFilterLastname(string from, string to);// define range /* by birthday */ void setFilterBirthday(dateType from, dateType to); /* clear all filters */ void clearFilters(); void print(int i);// print personal data of [i] person }; // Main program int main() { return 0; } /*****************implementation of print & set function*****/ // constructor with parameters addressType::addressType() { st_address = ""; city = ""; state = ""; zip = 0; } void addressType::set(string addr, string city, string state, int zip) { this->st_address = addr; this->city = city; this->state = state; this->zip = zip; } void addressType::setStreet(string street) { this->st_address = street; } string addressType::getStreet()const { return this->st_address; }
  • 6. void addressType::setCity(string street) { this->city = street; } string addressType::getState()const { return this->state; } void addressType::setState(string street) { this->st_address = street; } void addressType::setZip(int code) { this->zip = code; } int addressType::getZip()const { return this->zip; } /* personType implementation */ personType::personType() {// constructor this->setName("", ""); } personType::personType(string first, string last){// constructor this->setName(first, last); } void personType::setName(string first, string last) { firstName = first; lastName = last; } string personType::getFirstName()const { return firstName;
  • 7. } string personType::getLastName()const { return lastName; } void personType::print()const { cout << get() << " "; } string personType::get()const { return firstName + " " + lastName; } personType & personType::operator=(const personType & p) { setName(p.getFirstName(), p.getLastName()); return*this; } /* Constructor */ dateType::dateType() { setDate(1, 1, 1900); } dateType::dateType(int d, int m, int y) { setDate(d, m, y); } int dateType::getDay()const { return dDay; } int dateType::getMonth()const { return dMonth; } int dateType::getYear()const
  • 8. { return dYear; } void dateType::setDate(int d, int m, int y) { dDay = d; dMonth = m; dYear = y; } void dateType::print()const { cout << get() << " "; } string dateType::get()const { string a; a = dDay; a += "/"; a += dMonth; a += "/"; a += dYear; return a; } dateType & dateType::operator=(const dateType & d) { this->dDay = d.getDay(); this->dMonth = d.getMonth(); this->dYear = d.getYear(); return*this; } /* Implementation of extPersonType */ extPersonType::extPersonType() { phone = ""; group = UNFILLED; birthday.setDate(01, 01, 1900);
  • 9. } extPersonType::extPersonType(string first, string last) : personType::personType(first, last) { phone = ""; group = UNFILLED; birthday.setDate(01, 01, 1900); } void extPersonType::setBirthday(int d, int m, int y) { birthday.setDate(d, m, y); } dateType extPersonType::getBirthday()const { return birthday; } void extPersonType::setGroup(contactGroupType gr) { group = gr; } contactGroupType extPersonType::getGroup()const { return group; } void extPersonType::setPhone(string ph) { phone = ph; } string extPersonType::getPhone()const { return phone; } // Override parent's 'get()' add phone and birthday string extPersonType::get()const { string result; result = this->personType::get();
  • 10. result = result + " " + birthday.get() + " " + phone + " " + groupToString(group); return result; } extPersonType & extPersonType::operator=(const extPersonType & p) { // first call superclass' operator= (personType)*this = (personType)p; // now assign birthday, phone and category this->phone = p.getPhone(); this->birthday = p.getBirthday(); this->group = p.getGroup(); return*this; } string extPersonType::groupToString(contactGroupType a)const { string result; switch (a) { case FAMILY: result = "FAMILY"; break; case FRIEND: result = "FRIEND"; break; case BUSINESS: result = "BUSINESS"; break; case UNFILLED: result = ""; break; } return result; } contactGroupType extPersonType::stringToGroup(string a)const { contactGroupType result;
  • 11. if (a.compare("FAMILY") == 0) result = FAMILY; else if (a.compare("FRIEND") == 0) result = FRIEND; else if (a.compare("BUSINESS") == 0) result = BUSINESS; else result = UNFILLED; return result; } arrayListType::arrayListType() { size = 0; } int arrayListType::getSize()const { return size; } void arrayListType::removeLast() { size--; } void arrayListType::add(const extPersonType &p) { array[size++] = p; } extPersonType & arrayListType::operator[](int i) { return array[i]; } /* addressBookType implementation */ addressBookType::addressBookType() : arrayListType::arrayListType() { reset(); clearFilters(); } void addressBookType::reset() { current = 0; }
  • 12. void addressBookType::clearFilters() { fltStatus = fltDate = fltLast = fltDateRange = false; } /* Read array from file, return false on error */ bool addressBookType::readFile(string filename) { string line; string fields[_end + 1];// _last index of the last field extPersonType p;// temporary 'person' instance int pos1 = 0, pos2 = 0, index; fileStream.open(filename.c_str(), ios::in); reset();// reset 'current' counter clearFilters(); while (!fileStream.eof()){// read line by line fileStream >> line; // fields are in the following order: // first, last, street, city, state, zip, phone, status, year, month, day for (index = 0; index <= _end; index++) fields[index] = "";// initialize pos2 = 0; pos1 = -1; index = 0; do {// read field by field pos1 = pos2 + 1;// +1 is for field separator pos2 = line.find(FS, pos1); fields[index] = line.substr(pos1, pos2 - pos1);// get field from line index++; } while (pos2 >= 0 && index <= _end); // now fields[] are filled with fields from file p.setName(fields[_first], fields[_last]); p.setPhone(fields[_phone]); p.setGroup(p.stringToGroup(fields[_group]));// convert string to enum // set birthday p.getBirthday().setDate(atoi(fields[_month].c_str()), atoi(fields[_day].c_str()),
  • 13. atoi(fields[_year].c_str())); // add 'p' to array this->add(p); } // while () next line from file fileStream.close(); return true; } // Write to file (stub) bool addressBookType::writeFile(string filename) { return true; } Solution Actually while initializing constructors, you should not use :: operator for calling base class constructor. See my modification below. Remove :: operator for base class. Ex: while initializing child class, Child::Child(): Base(){ /// Here you used Base::Base() which is wrong(for some compilers) // } And also include header files. That's it. Apart from these things, your code is perfectly alright. ===================================================================== ============================ extPersonType::extPersonType(string first, string last) : personType::personType(first, last) { phone = ""; group = UNFILLED; birthday.setDate(01, 01, 1900); } Change the above part of the code as below extPersonType::extPersonType(string first, string last) : personType(first, last) {
  • 14. phone = ""; group = UNFILLED; birthday.setDate(01, 01, 1900); } ===================================================================== ============================ /* addressBookType implementation */ addressBookType::addressBookType() : arrayListType::arrayListType() { reset(); clearFilters(); } change the above part of the code to addressBookType::addressBookType() : arrayListType() { reset(); clearFilters(); }