I am little confused, maybe a little overwhelmed because we are just getting into the various storage classes and scopes, and also arrays. My biggest issue is getting my functions and data members recognized in the separate files. I was able to do this with a project I had on an array.
But now I am struggling with another issue: getting my objects recognized. And also, must I always have an object? Because an object is part of the OOA/OOD?
My program deals with just printing charts showing the Fahrenheit and Celsius equivalents. Here is my error:
.cpp(33) : error C2228: left of '.displayFahrenheit' must have class/struct/union
.cpp(34) : error C2228: left of '.displayCelsius' must have class/struct/union
#include "Temperatures.h"
int main()
{
// create the object
Temperatures degrees();
// display the temperatures
degrees.displayFahrenheit();
degrees.displayCelsius();
cout << endl;
return 0;
}
Also, here are my function definitions:
#include <iostream>
using namespace std;
#include <iomanip>
using std::setw;
#include "Temperatures.h"
// function fahrenheit returns the Fahrenheit equivalent of a Celsius temperature
double Temperatures::fahrenheit(int countCelsius)
{
return (((countCelsius * 9.00) / 5.00) + 32);
}
// function celsius returns the Celsius equivalent of a Fahrenheit temperature
double Temperatures::celsius(int countFahrenheit)
{
return ((countFahrenheit - 32) / (5.00/9.00));
}
// function displayFahrenheit
void Temperatures::displayFahrenheit()
{
cout << "Fahrenheit equivalents for Celsius 0 to 100 degrees are: \n";
for(int counter = 0; counter <= 100; counter++)
{
cout << setprecision(2) << showpoint << fixed << setw(5) << fahrenheit(counter);
if(counter % 10 == 0)
cout << endl;
}
}
// function displayCelsius
void Temperatures::displayCelsius()
{
cout << "\nCelsius equivalents of Fahrenheit 32 to 212 degrees: \n";
for(int counter2 = 32; counter2 <= 212; counter2++)
{
cout << setw(5) << celsius(counter2);
if(counter2 % 10 ==0)
cout << endl;
}
}