I need some assistance

I am new to programming, and I am having trouble understanding the srand(time(0). I am using it to create a program that will generate random times of the day.

I have defined my class time as follows:

// Time.h
// class Time definittion

#ifndef TIME_H
#define TIME_H

class Time
Time( int =0, int =0, int=0 );

void setime( int, int, int ) const;

void setHour( int ) const;
int getHour() const;

void setMinute( int ) const;
int getMinute() const;

void setSecond( int ) const;
int getSecond() const;

void printUniversal() const;
void printStandard();

int hour;
int minute;
int second;
}; // end class Time

I am trying to use class to create a derived RandTime.h class to generate a random time of day.

I have already created a abstract base class that will be used to generate random numbers or strings in various questions.

1) I am unsure of my headers to use in the RandTime class


2) I am unsure how to properly use Srand

I have started with my header files:

// RandTime.cpp
// Derived class that generates a random time
// of day using the Time class

#include "stdafx.h"
#include "time.h"

#include <iostream>
#include <ctime>
#include <iostdlib>
using namespace std;

int main()
srand time (0);
cout << time;

Please Help
srand() is a function, and not a type. You would call srand like this:


Try not to call srand more then once.
Topic archived. No new replies allowed.