/***************************************************************
* Name: Rafael Orta
* Course: Computer Science & Programming
* Class: CS04103 Section: 4 & 5
* Assignment Date: 04/08/18
* File Name: liveDemo1.cpp
*****************************************************************
* ID: N/A
* Purpose: To provide an example of class ussage in C++, it asks for
* a number and raises its value to the power of two.
*****************************************************************/
//#include "stdafx.h"
#include "powerofTwo.h"
#include <iostream>
using namespace std;
int main()
{
double number;
powerofTwo p2; // I am instantiating an object of the class type.
cout << "\nInsert the number that you would like to be raised to the power of 2: ";
cin >> number;
p2.getPower(number); // I am calling a method of the class through a getter.
cout << "\n The result is : " << number << endl;
return 0;
}
//#pragma once
#ifndef POWEROFTWO_H
#define POWEROFTWO
class powerofTwo // Very similar to your function prototype.
{
public:
// Modifier
void getPower(double&);
private:
};
#endif // !POWEROFTWO_H
//#include "stdafx.h"
#include "powerofTwo.h"
using namespace std;
void powerofTwo::getPower(double& number) // Very similar to your function implementation.
{
number = number * number;
}