Code compiles w/o error but print function does not pull data from base class. I have looked over the chapter numerous times. This is a long one, sorry

class extClockType: public clockType
{
  public:
	void getTimeZone(int& timeZone);
	void setTimeZone(int timeZone);
	void printTime() const;
	extClockType();
	extClockType(int hours, int minutes, int seconds, int timeZone);
  private:
	int tz;
};


#include <iostream>
#include "clockType.h"
#include "extClockType.h"

using namespace std;


void extClockType::setTimeZone(int timeZone)
{
	if(tz <= 12 && tz >= -12)

    tz = timeZone;

    else

    tz = 0;
}

void extClockType::getTimeZone(int& timeZone)
{
	timeZone = tz;
}

void extClockType::printTime() const
{
	clockType::printTime();
	cout << "  timezone is: ";
	if(tz >= 0)
    cout << "GMT+" << tz;
	else 
	cout <<"GMT" << tz;
}

extClockType::extClockType(int hours, int minutes, int seconds, int timeZone): clockType(hours, minutes, seconds)
{
	if(tz <= 12 && tz >= -12)

    tz = timeZone;

	else

    tz = 0;
}

extClockType::extClockType() 
{
	tz = 0;	
}

class clockType
{
public:
    void setTime(int hours, int minutes, int seconds); 
    void getTime(int& hours, int& minutes, int& seconds) const;
    void printTime() const;
    void incrementSeconds();
    void incrementMinutes();
    void incrementHours();
    bool equalTime(const clockType& otherClock) const;
    clockType(int hours, int minutes, int seconds);
    clockType();
private:
    int hr;
    int min;
    int sec;
};

#include <iostream>
#include "clockType.h"

using namespace std;

void clockType::setTime(int hours, int minutes, int seconds)
{
	if (0 <= hours && hours < 24)
	    hr = hours;
	else 
	    hr = 0;

	if (0 <= minutes && minutes < 60)
	    min = minutes;
	else 
	    min = 0;

	if (0 <= seconds && seconds < 60)
	    sec = seconds;
	else 
	    sec = 0;
}

void clockType::getTime(int& hours, int& minutes, int& seconds) const
{
	hours = hr;
	minutes = min;
	seconds = sec;
}

void clockType::incrementHours()
{
	hr++;
	if(hr > 23)
 	   hr = 0;
}

void clockType::incrementMinutes()
{
	min++;
	if (min > 59)
	{
	    min = 0;
	    incrementHours();
	}
}

void clockType::incrementSeconds()
{
	sec++;

	if (sec > 59)
	{
	    sec = 0;
	    incrementMinutes();
	}
}

void clockType::printTime() const
{
	if (hr < 10)
	    cout << "0";
	cout << hr << ":";

	if (min < 10)
	    cout << "0";
	cout << min << ":";

	if (sec < 10)
	   cout << "0";
	cout << sec;
}

bool clockType::equalTime(const clockType& otherClock) const
{
	return (hr == otherClock.hr 
		    && min == otherClock.min 
		    && sec == otherClock.sec);
}

clockType::clockType(int hours, int minutes, int seconds)
{
	if (0 <= hours && hours < 24)
		hr = hours;
	else
		hr = 0;

	if (0 <= minutes && minutes < 60)
		min = minutes;
	else
		min = 0;

	if (0 <= seconds && seconds < 60)
		sec = seconds;
	else
		sec = 0;
}

clockType::clockType()
{
	hr = 0;
	min = 0;
	sec = 0;
}

#include <iostream>
#include "clockType.h"
#include "extClockType.h"

using namespace std;

int main()
{
	int hours;
    int minutes;
    int seconds;
	int timeZone;

	clockType clockOne;
	clockType clockTwo;

    extClockType tzClock;
	extClockType tzClock2;
		
    clockOne.setTime(9, 30, 26); 
	tzClock.setTimeZone(8);
	cout << "Clock One's time is currently: ";
	tzClock.printTime();
	clockOne.printTime();
    cout << endl;  

    clockTwo.setTime(9, 30, 28);
	tzClock2.setTimeZone(7);
	cout << "Clock Two's time is currently: ";
	tzClock2.printTime();
    cout << endl;
   
    if (clockOne.equalTime(clockTwo))
        cout << "Both times are equal."
             << endl;
    else
	{
    cout << "Both times are not equal."
             << endl;
    cout << "Please, enter the current time"
		<< "(hrs, mins, secs, and timezone): ";
    cin >> hours >> minutes >> seconds >> timeZone;
    
    clockOne.setTime(hours, minutes, seconds);
	tzClock.setTimeZone(timeZone);
	cout << "The time is has been set to: ";
	tzClock.printTime();
	cout << endl;
	}

    clockOne.incrementSeconds();
    cout << "After incrementing the time by one second: ";
	tzClock.printTime();
    cout << endl;
    
    clockOne.getTime(hours, minutes, seconds);
	tzClock.getTimeZone(timeZone);
	     
    cout << "hours = " << hours 
         << ", minutes = " << minutes
         << ", seconds = " << seconds << endl;

	return 0;
}

will someone please help with this problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.