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
C++ Class involving difference. The goal is to overload the function: void Bag::operator-=(const Bag& a_bag) //...
C++ Class involving difference. The goal is to overload the function: void Bag::operator-=(const Bag& a_bag) // The Set Difference between two sets A and B is the set that consists of the elements of A which are not elements of B. Bag bag1 = (1,2,3) and Bag bag2 = (2,4,5) then bag1-=bag2 should return 1,3,4,5. //parameter a_bag to be subtracted from this (the calling) bag //post removes all data from items_ that is also found in a_bag //Since type is...
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...
Implement and demonstrate a disk-based buffer pool class based on the LRU buffer pool replacement strategy....
Implement and demonstrate a disk-based buffer pool class based on the LRU buffer pool replacement strategy. Disk blocks are numbered consecutively from the beginning of the file with the first block numbered as 0. Assume that blocks are 4096 bytes in size. Use the supplied C++ files to implement your LRU Buffer Pool based on the instructions below. • Implement a BufferBlock class using the supplied BufferBlockADT.h o Your Buffer Block must inherit BufferBlockADT or you will not get credit...
/* 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);...
IntNode class I am providing the IntNode class you are required to use. Place this class...
IntNode class I am providing the IntNode class you are required to use. Place this class definition within the IntList.h file exactly as is. Make sure you place it above the definition of your IntList class. Notice that you will not code an implementation file for the IntNode class. The IntNode constructor has been defined inline (within the class declaration). Do not write any other functions for the IntNode class. Use as is. struct IntNode { int data; IntNode *next;...
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...
#ifndef BAG_H #define BAG_H #include <cstdlib> // Provides size_t using namespace std; class bag { public:...
#ifndef BAG_H #define BAG_H #include <cstdlib> // Provides size_t using namespace std; class bag { public: // TYPEDEFS and MEMBER CONSTANTS typedef int value_type; typedef std::size_t size_type; static const size_type CAPACITY = 30; // CONSTRUCTOR bag() {used = 0;} // MODIFICATION MEMBER FUNCTIONS size_type erase(const value_type& target); bool erase_one(const value_type& target); void insert(const value_type& entry); void operator +=(const bag& addend); void sort(const bag& b); //Sort the array in the bag object // CONSTANT MEMBER FUNCTIONS size_type size( ) const {...
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...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT