**Create your own pie chart with ChartMaker


A+    A−    B  
Home
Algebra
Math Games
  • Decimals in Space
  • Fraction Balls
  • Integers in Space
  • Math Man
  • Number Balls
  • Geometry
    Interactive
    Trigonometry
    Jobs
  • Tutoring jobs
  • New York Tutoring Jobs
  • White Plains, NY
  • Westchester County, NY
  • Chicago Math Jobs
  • Philadelphia
  • Teacher Resources
    On FaceBook!

    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