//I need help please?

#include<stdio.h>
#include<iostream.h>

class Time
{
	public:
		Time();
		~Time();
		void setTime(int, int, int);
		void printMilitary();
		void printStandard();
	private:
		int hour, minute, second;
};

void Time::printMilitary()
{
	cout<<"Military time: "<<hour<<minute<<second;
}

Time::Time()
{
	hour=minute=second=0;
}

Time::~Time()
{
	cout<<endl<<"Destructor code.";
}

void main()
{
	Time wakeup, samplePM;
	wakeup.setTime(6, 5, 0);
	samplePM.setTime(15, 30, 24);
	cout<<"I wake up at";
	wakeup.printMilitary();
	cout<<"\nIn standard time: ";
	wakeup.printStandard();
	cout<<"\nIn Snack time: ";
	samplePM.printMilitary();
	cout<<"\nIn standard time: ";
	samplePM.printStandard();
	getch();
}

//It has an error, it says:

//function 'getch' should return a value
//Why did the compiler treat it as a function and are the header files lacking or what?
//thanks

You got a few things to take care of which may or may not directly be related to your problem:

1. Please in the future, when you post on the forum, wrap your code with code tags.
2. void main() is bad, for many reasons. instead, use int main() which will return 0 upon successful termination of your program.
3. How did you even make it this far without deriving objects from the standard namespace? Try adding using namespace std; on the 3rd line of your code.
4. Format your code nicely. Just like you indent between paragraphs when you write a paper, you should indent blocks of similar code.

//Why did the compiler treat it as a function...

Because it IS a function.

... and are the header files lacking or what?

No, you are lacking the header file.

But why do you want to use a non-standard C function when a standard C++ function works just fine? Use cin.get() Also, main() is an int function, not a void function. See this

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.