I am trying to run this program, in this I have a class clocktype with its header file and implementation file. Now I am trying to inherit this class to implement a new function called timezone.
The build is successful but I have 2 errors while compiling here is my code:

//header file clocktype
#ifndef h_clocktype
#define h_clocktype
#include<string>
using namespace std;


class clocktype
{
public:
	void settime(int hours, int minutes, int seconds);
	void gettime(int& hours, int& minutes, int& seconds);
	void printtime();
	void incseconds();
	void incminutes();
	void inchours();

	clocktype (int hours, int minutes, int seconds);
	clocktype();

protected:
	int hr;
	int min;
	int sec;
};
#endif;

// implemnetation file
#include<iostream>
#include<conio.h>
#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)
{
	hours=hr;
	minutes=min;
	seconds=sec;
}

void clocktype::printtime()
{
	if(hr<10)
		cout<<"0";
		cout<<hr<<":";
	if(min<10)
		cout<<"0";
	cout<<min<<":";
	if(sec<10)
		cout<<"0";
	cout<<sec;
}

void clocktype::inchours()
{
	hr++;
	if(hr<23)
		hr=0;
}
void clocktype::incminutes()
{
	min++;
	if(min<59)
		min=0;
	inchours();
}
void clocktype::incseconds()
{
	sec++;
	if(sec<59)
		sec=0;
	incminutes();
}

clocktype::clocktype()
{
	hr=0;
	min=0;
	sec=0;
}
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;
}

// main function

int main()
{
	clocktype myclock;
	myclock.settime( 12, 14, 40);
	cout<<" The time now is : ";
		myclock.printtime();
	myclock.settime( 24, 60, 60);
	cout<<"\n The time now is : ";
	myclock.printtime();

	getch();
}

// header for the derived class
#ifndef h_clocktype2
#define h_clocktype2
#include<iostream>
#include"clocktype.h"
using namespace std;

enum zonetype {GMT, EST, PST, IST, CET};
class clocktype2: public clocktype
{
	public:
	void settime(int hours, int minutes, int seconds,zonetype timezone);
	void gettime(int hours, int minutes, int seconds,zonetype timezone);
	void printtime();
	
	clocktype2 (int hours, int minutes, int seconds, zonetype timezone);
	clocktype2();

private:
	zonetype tz;
};
#endif;

// implementation file for derived class
#include<iostream>
#include<conio.h>
#include"clocktype.h"
#include"clocktype2.h"


using namespace std;

void clocktype2::settime(int hours, int minutes, int seconds, zonetype timezone)
{
	hours=hr;
	minutes=min;
	seconds=sec;
	timezone=tz;

}
void clocktype2::printtime()
{
	static string zonetype[5]={"GMT", "EST", "PST", "IST", "CET"};
}
clocktype2::clocktype2(){
hr=0;
	min=0;
	sec=0;
	tz=GMT;
		   }

clocktype2::clocktype2(int hours, int minutes, int seconds, zonetype timezone)
{
hours=hr;
	minutes=min;
	seconds=sec;
	timezone=tz;
}

int main()
{
	clocktype2 clock;
	clock.settime( 12, 14, 40, GMT);
	cout<<" The time now is : ";
		clock.printtime();
	clock.settime( 24, 60, 60, IST);
	cout<<"\n The time now is : ";
	clock.printtime();

	return(0);
}

>>The build is successful but I have 2 errors while compiling here is my code
Um, last I checked, if you have 2 errors while compiling, the build isn't successful...

It might be useful if you shared those errors. Very few, if any, of us are psychics. We can't even begin to help unless you give us the relevant information.

Oh I am sorry the error it give me is this:

------ Build started: Project: lab-4, Configuration: Debug Win32 ------
Linking...
clocktypeimp2.obj : error LNK2019: unresolved external symbol "public: __thiscall clocktype::clocktype(void)" (??0clocktype@@QAE@XZ) referenced in function "public: __thiscall clocktype2::clocktype2(void)" (??0clocktype2@@QAE@XZ)
C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\lab-4\Debug\lab-4.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\lab-4\lab-4\Debug\BuildLog.htm"
lab-4 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

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.