1 Replies - 603 Views - Last Post: 25 April 2011 - 11:17 AM Rate Topic: -----

#1 starkhavenprincessrin  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 31-March 11

Declaring class objects and making functions for them.

Posted 25 April 2011 - 11:11 AM

Okay so I have to complete this program and I was sick the day that my class talked about how to do these functions and use objects. I'm not sure what it is I'm supposed to do with it so any hints or helpful information will be welcomed.

Here's the code for it
// CS 200 In-class exercise 10
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
using namespace std;

//  in the <ctime> library is a function   time(0)
//     that returns the number of seconds since 1/1/1970 when the function is called
//  to compute an elapsed time
//      1st - call time(0) and remember the value
//      2nd - at a time in the future, call time(0) again
//               and subtract the remembered value 
//               -  that will give you the elapsed time
//

class Timer
{
public:
	//  declare a default constructor




	//  declare a function to return the age of the timer object in seconds
	//   NOTE:  - the age is an elapsed time from when the object was created
	//          - call the age function a little later, and the age is greater



private:
	//  declare the data needed to implement the class



};

//  write the 2 member functions







//  test the 2 member functions

void main()
{
	double x = 300.0;  //a number to take the sqrt of
	int i; // index for our loop

	// declare a Timer object


	// make some elapsed time go by
	for (i=0; i < 100000000; i++)
	{
		sqrt(x);
	}

	// find out and display how old the object is now


	return;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Declaring class objects and making functions for them.

#2 TomJoad  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 54
  • Joined: 01-December 10

Re: Declaring class objects and making functions for them.

Posted 25 April 2011 - 11:17 AM

Are you trying to learn classes?

http://www.learncpp....-class-members/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1