is this better
Code:#ifndef _FUNCTIONS_H_
#define _FUNCTIONS_H_
class BaseFunction
{
private:
protected:
public:
BaseFunction();
virtual int Menu() = 0;
};
class Functions : public BaseFunction
{
private:
public:
Functions();
void kg_to_lbs();
void c_to_k();
void tsp_to_ml();
void m_table();
void s_table();
virtual int Menu() override;
};
Code:#include "stdafx.h"
#include "Functions.h"
#include <iostream>
using namespace std;
BaseFunction::BaseFunction()
{
cout << "Constructing base class..." << endl;
}
Functions::Functions()
{
cout << "Constructing derived class..." << endl;
}
void Functions::kg_to_lbs()
{
cout << "changing kilograms to pounds" << endl;
}
void Functions::c_to_k()
{
cout << "changing celsius to degrees" << endl;
}
void Functions::tsp_to_ml()
{
cout << "changing teaspoons to millilitres" << endl;
}
void Functions::m_table()
{
cout << "multiplying" << endl;
}
void Functions::s_table()
{
cout << "squaring" << endl;
}
int Functions::Menu()
{
int opt;
do {
for (int i = 1; i <= 5; i++)
cout << "Function " << i << " [" << i << ']' << endl;
cout << "Quit [0]\nEnter Option: ";
cin >> opt;
} while (opt < 0 || opt > 5);
return opt;
}
Code:#include "stdafx.h"
#include <iostream>
#include "Functions.h"
using namespace std;
int main()
{
int opt;
Functions *f = new Functions();
do {
opt = f->Menu();
switch (opt)
{
case 1:
f->kg_to_lbs(); break;
case 2:
f->c_to_k(); break;
case 3:
f->tsp_to_ml(); break;
case 4:
f->m_table(); break;
case 5:
f->s_table(); break;
}
} while (opt != 0);
}