**Interactive demonstration of a mathematical relation. See ball drop as a function of distance over time.


A+    A−    B  
Home
Algebra
Math Games
Geometry
Private Tutors
Interactive
Trigonometry
Jobs
Teacher Resources

AddThis Social Bookmark Button

C++ Classes

#include "nameOfMyClass.h"

Related Links: random numbers | Square Root c++ home

Types of Files

In Java In C++
Method headers and implementation are in the same file and the class name must match the file name. Below is an example of partially functional Java Class. This class must be saved in a file name PrimeFactory.java
	public class PrimeFactory{
	
	//default constructor
	public PrimeFactory(){
	}
	
	public boolean isPrime(int num){
	for(int i=3;i < Math.sqrt(num);i++)
	 if(num %i==0)
	 	return false;

return (num ==2);
	}
	
	
	}
	
Method Headers and implementations should be saved in two distinct files. One file is the header file and has a '.h' extension such as PrimeFactory.h . This file is similar to a Java interface in that it specifies the method headers. The other file is the source code file and provides the 'code' that implements the header file. This file can have various extensions including '.c' and '.cpp' such as PrimeFactory.cpp.
Random Number
#include < cstdlib >
example
int  r = rand();
now r holds a value between 0 and RAND_MAX
Top
AddThis Social Bookmark Button