1. is this better

Code:
``` #ifndef _FUNCTIONS_H_
#define _FUNCTIONS_H_

class BaseFunction
{
private:

protected:

public:
BaseFunction();
};

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();
};```
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 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 {
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);
}```

2. That's a lot better actually. But you are still only about half done! The menu function still hasn't been changed to plainly state the options the user has. Plus, you need to change the rest of the functions so that when they are called, they take the users input, do the math, and display the answer.

The conversion functions should be easy because they are simple operations: for kg to pounds and teaspoons to mils, all you do is multiply a constant. For C to kelvin, all you do is add a constant.

The multiplication and square tables are a bit different, but again, with a basic understanding of loops, you should be able to fill row and column with answers.

3. Originally Posted by whiteflags
I'm really not sure what to say. I'm also tempted to call this approach over-engineered for a beginner.

It feels like an array is getting preferential treatment just because the names were originally enumerated. A static class keeps everything as organized as an array would. The best thing that could be said for an array of function pointers in this program is that it supplants a switch. Personally, I find the switch to be clearer code.

It's not the worst idea, I just don't think it's something people need to learn early on. At least I suspect that sonicflare9 hasn't been at this very long.
I suggested changing to an array because of all the stylistic issues with the code, I felt that "Don't repeat yourself" was the most important one to point out. Also, I would expect not function pointers, but function objects, derived from BaseFunction. Sonicflage9's code is already half way to doing it this way. That's another reason I made my suggestion: where ever sonicflage9 got the idea to use "Basefunction" from, seemed to have an array of polymorphic objects in mind.

But sonicflage9 has implemented it as a you suggested. Which is great. @sonicflage9, doing it this way, you don't need BaseFunction.

On using static functions, I still disagree that it's a good idea. It does not organize things like an array, it organizes things like a namespace. But for that I suggest a namespace. Which, for sonicflage9's sake, looks like this:
Code:
```namespace Functions {
void kg_to_lbs();
void c_to_k();
void tsp_to_ml();
void m_table();
void s_table();
};

//use as
case 1:
Functions::kg_to_lbs();    break;
case 2:
Functions::c_to_k();    break;```

4. how do i fix the error uninitilized local variable kg used

5. Originally Posted by sonicflare9
how do i fix the error uninitilized local variable kg used
If you're talking about your old code from page one, that question has already been answered; otherwise, post and example. Try to explain to yourself what your functions do step-by-step, as if you had to explain it to someone else; that's a good way to find mistakes.

6. I need help
Code:
``` #ifndef _FUNCTIONS_H_
#define _FUNCTIONS_H_

#include <iostream>
#include <string>

enum Options { NORMAL_EXIT, KG_TO_LBS, CELSIUS_TO_KELVIN, TSP_TO_ML, M_TABLE, S_TABLE };

class game
{
private:

protected:

public:
game();
};

class Functions
{
public:
static double GetDouble(const std::string& prompt);
static int GetInt(const std::string& prompt);
static double ConvertCelsiusToKelvin(double c);
static double ConvertKgToLbs(double kg);
static double ConvertTspToMl(double tsp);
static void MulTable(int first, int last);
static void SquareTable(int first, int last, unsigned int step);
};

#endif```
Code:
``` #include "stdafx.h"
#include <iostream>
#include "Functions.h"

using namespace std;

int main()
{
int opt;
Functions *f = new Functions();
do {
switch (opt)
{
case 1:
f->ConvertKgToLbs();    break;
case 2:
f->ConvertCelsiusToKelvin();    break;
case 3:
f->ConvertTspToMl();    break;
case 4:
f->MulTable();    break;
case 5:
f->SquareTable();    break;
}
} while (opt != 0);
}```
Code:
``` #include "stdafx.h"
#include "Functions.h"
#include <iostream>
using namespace std;

double Functions::GetDouble(const std::string & prompt)
{
return 0.0;
}

int Functions::GetInt(const std::string & prompt)
{
return 0;
}

{
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;
}

double Functions::ConvertCelsiusToKelvin(double c)
{
return 0.0;
}

double Functions::ConvertKgToLbs(double kg)
{
return 0.0;
}

double Functions::ConvertTspToMl(double tsp)
{
return 0.0;
}

void Functions::MulTable(int first, int last)
{
}

void Functions::SquareTable(int first, int last, unsigned int step)
{
}```

7. So you're back to square one? Start by implementing the functions. For instance ConvertCelsiusToKelvin should be trivial to figure out. Don't be a leech, get started!

8. how do i fix too few arguments in function call

9. Originally Posted by sonicflare9
how do i fix too few arguments in function call
• Call the function with sufficient arguments, or
• Change the function definition to have the necessary number of parameters to match the call (if it turns out that you wrote the function with unused parameters)

10. can i have an example

11. Sure, here is a program with a negative example. Fix it:
Code:
```#include <iostream>

void foo(int n)
{
std::cout << n << std::endl;
}

int main()
{
foo(); // prints 123
}```

12. #include <iostream>
Code:
```void foo(int n)
{
std::cout << n << std::endl;
}

int main()
{
foo(123); // prints 123
}```
so all i have to do is add numbers in the brackets?

how can i make the 1-5 work

13. Code:
``` #include "stdafx.h"
#include "Functions.h"
#include <iostream>
using namespace std;

double kg;
double lb;

double Functions::GetDouble(const std::string & prompt)
{
return 0;
}

int Functions::GetInt(const std::string & prompt)
{
return 0;
}

double Functions::ConvertCelsiusToKelvin(double c)
{
return 0.0;
}

double Functions::ConvertKgToLbs(double kg)
{
return 0.0;
}

double Functions::ConvertTspToMl(double tsp)
{
return 0.0;
}

void Functions::MulTable(int first, int last)
{
}

void Functions::SquareTable(int first, int last, unsigned int step)
{
}

{
double kg, lb;
kg = 50;
cout << "this will maybe convert kilograms to pounds.\n";
cout << "please enter weight in kilograms" ;
cin >> lb;
lb = kg * 2.2;
cout << "The weight in kilograms is: " << kg << '\n';

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:
``` #ifndef _FUNCTIONS_H_
#define _FUNCTIONS_H_

#include <iostream>
#include <string>

enum Options { NORMAL_EXIT, KG_TO_LBS, CELSIUS_TO_KELVIN, TSP_TO_ML, M_TABLE, S_TABLE };

class game
{
private:

protected:

public:
game();
};

class Functions
{
public:
static double GetDouble(const std::string& prompt);
static int GetInt(const std::string& prompt);
static double ConvertCelsiusToKelvin(double c);
static double ConvertKgToLbs(double kg);
static double ConvertTspToMl(double tsp);
static void MulTable(int first, int last);
static void SquareTable(int first, int last, unsigned int step);
};

#endif```
Code:
``` #include "stdafx.h"
#include <iostream>
#include "Functions.h"

using namespace std;

int main()
{
int opt;
Functions *f = new Functions();
do {
switch (opt)
{
case 1:
f->ConvertKgToLbs(100);    break;
case 2:
f->ConvertCelsiusToKelvin(100);    break;
case 3:
f->ConvertTspToMl(100);    break;
case 4:
f->MulTable(12, 12);    break;
case 5:
f->SquareTable(1, 2, 3);    break;
}
} while (opt != 0);
}```