Question

Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in...

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;

}

Homework Answers

Answer #1


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();
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Complete the missing code for the constructors as indicated in the comments in all three header...
Complete the missing code for the constructors as indicated in the comments in all three header files. C++ mainDriver.cpp #include <string> #include "Address.h" #include "Date.h" #include "Person.h" using namespace std; int main() {    Person p1;    Person p2("Smith", "Bobby", "[email protected]", 111, "Main St", "Clemson",            "SC", 29630, 1, 31, 1998);    cout << endl << endl;    p1.printInfo();    p2.printInfo();    return 0; } Person.h #ifndef PERSON_H #define PERSON_H #include <iostream> #include <string> using namespace std; class...
/* Write a function that looks for a particular person in their respective linked list The...
/* Write a function that looks for a particular person in their respective linked list The only place you need to write code is the "find" method in the linked list class */ #include <bits/stdc++.h> using namespace std; string ltrim(const string &); string rtrim(const string &); #define BUFFLEN 10 /* Each "person" is defined by their name, zipcode, and their pet's name. Persons are hashed by their zipcode. */ //---------------------------------------------------------------------------- /* function declarations ------------------------*/ int computeKey(int); void add_to_buffer(string,int,string); void find_in_buffer(int);...
Write a template-based class that implements a template-based implementation of Homework 3 that allows for any...
Write a template-based class that implements a template-based implementation of Homework 3 that allows for any type dynamic arrays (replace string by the template in all instances below). • The class should have: – A private member variable called dynamicArray that references a dynamic array of type string. – A private member variable called size that holds the number of entries in the array. – A default constructor that sets the dynamic array to NULL and sets size to 0....
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with...
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with the default values denoted by dataType name : defaultValue - String animal : empty string - int lapsRan : 0 - boolean resting : false - boolean eating : false - double energy : 100.00 For the animal property implement both getter/setter methods. For all other properties implement ONLY a getter method Now implement the following constructors: 1. Constructor 1 – accepts a String...
My assignment: Triplet Template Class Directions: Define a template class for a generic triplet. The private...
My assignment: Triplet Template Class Directions: Define a template class for a generic triplet. The private data member for the triplet is a generic array with three elements. The triplet ADT has the following functions:  default constructor  explicit constructor: initialize the data member using parameters  three accessors (three get functions) which will return the value of each individual element of the array data member  one mutator (set function) which will assign values to the data member...
Data Structures using C++ Consider the classes QueueADT and ArrayQueueType: QueueADT: #ifndef QUEUEADT_H #define QUEUEADT_H template...
Data Structures using C++ Consider the classes QueueADT and ArrayQueueType: QueueADT: #ifndef QUEUEADT_H #define QUEUEADT_H template <class ItemType> class QueueADT { public:        // Action responsibilities        virtual void resetQueue() = 0;           // Reset the queue to an empty queue.           // Post: Queue is empty.        virtual void add(const ItemType& newItem) = 0;           // Function to add newItem to the queue.           // Pre: The queue exists and is not full.          ...
I am a beginner when it comes to java codeing. Is there anyway this code can...
I am a beginner when it comes to java codeing. Is there anyway this code can be simplified for someone who isn't as advanced in coding? public class Stock { //fields private String name; private String symbol; private double price; //3 args constructor public Stock(String name, String symbol, double price) { this.name = name; this.symbol = symbol; setPrice(price); } //all getters and setters /** * * @return stock name */ public String getName() { return name; } /** * set...
THIS IS FOR JAVA I have to write a method for a game of Hangman. The...
THIS IS FOR JAVA I have to write a method for a game of Hangman. The word the user is trying to guess is made up of hashtags like so " ###### " If the user guesses a letter correctly then that letter is revealed on the hashtags like so "##e##e##" If the user guesses incorrectly then it increments an int variable named count " ++count; " String guessWord(String guess,String word, String pound) In this method, you compare the character(letter)...