//========================================================================================
// Name : area.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Calculates the area of any shape and gives a little description
//========================================================================================
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
using namespace std;
void OpeningInputFile (ifstream& infile);
void OpeningOutputFile (ofstream& outfile);
void ClosingInputFile (ifstream& infile);
void ClosingOutputFile (ofstream& outfile);
void MainMenu ();
void PickShape ();
void GoodBye ();
int main()
{
ifstream infile;
ofstream outfile;
OpeningInputFile (infile);
OpeningOutputFile (outfile);
ClosingInputFile (infile);
ClosingOutputFile (outfile);
return 0;
}
void MainMenu ()
{
int ans;
cout << "Main Menu -- Chose what you want to do" << endl;
cout << "All shapes are given from 2D to 10D" << endl;
cout << "1: Pick which shape" << endl;
cout << "2: exit" << endl;
cin >> ans;
switch (ans)
{
case 1: PickShape (); break;
case 2: GoodBye (); break;
}
}
//========================================================================================
// Name : Files - opening and closing
// Precondition : Nothing
// Postcondition: opens and closes files
// Description : files are opened or closed depending on which function does it's job
//========================================================================================
void OpeningInputFile (ifstream& infile)
{
infile.open("shape.dat");
if(infile.fail())
{
cerr << "The file could not be opened" << endl;
exit (1);
}
else
cout << "The file was opened" << endl;
}
void OpeningOutputFile (ofstream& outfile)
{
outfile.open("shape.dat");
if(outfile.fail())
{
cerr << "The file could not be opened" << endl;
exit (1);
}
else
cout << "The file was opened" << endl;
}
void ClosingInputFile (ifstream& infile)
{
infile.close();
cout << "The file was closed" << endl;
}
void ClosingOutputFile (ofstream& outfile)
{
outfile.close();
cout << "The file was closed" << endl;
}
Why is it when I put a function in a switch command I get 2 errors. One being a make *** [area of shape] Error 1 and symbol(s) not found for architecture x86_64