Hello az1234,
Both H00G0 and dutch make good points.
When I tried to compile the code the first thing I noticed is:
Without something to follow the "#ifndef" all the code that follows is not part of the program. It is like putting a comment on each line.
I think you should find this better:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#ifndef MYFUNCTIONS_h
#define MYFUNCTIONS_h
typedef int Item;
class MyFunction
{
private:
static const int MAXSIZE = 100;
Item arr[MAXSIZE];
Item arr2[MAXSIZE];
public:
void sortArrays();
void setArrays();
};
#endif // !end MYFUNCTIONS_H
|
When you define a variable as a constant it is customary to use capital letters for the variable name.
Your header file includes the header file "string", but there is nothing in that file that needs the "string" header. By putting "#include <string>" in the header you could include this in a ".cpp" file that does not need it.
It has been said the the order of the "#include" files should make no difference, but sometimes it does.
For what you have I would do this in the "MyFunctions.cpp file:
1 2 3 4 5 6 7 8
|
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include "My Functions.h"
//using namespace std; // <--- Best not to use.
|
By keeping an order something like this I find it helps to remember what you need or what you have left out. And I have found that any include file that is in quotes is best put last and most of the time the include files that precede it will cover anything in that header file that might need them.
When it comes to "using namespace std;" you should not put this in a header file. That is asking for trouble. Give this a read
http://www.lonecpluspluscoder.com/2012/09/22/i-dont-want-to-see-another-using-namespace-xxx-in-a-header-file-ever-again/
Actually it is best not to use "using namespace std;" in any file. What you are missing out on now is learning what is in the standard name space slowly. Then someday you will have to learn everything at one time.
The function that you have says "sortArrays()", but the code is to read a file not sort. Consider changing the name of this function.
Your "MyFunctions.cpp" has "#include <sstream>", but you never use it.
dutch's code can easily be changed to use arrays, if that is what you need, instead of vectors. I would help to know what you can or have to use for this program.
As H00G0 said the rest of your code would be helpful. Also the input file that you are using would be a big help so that everyone is using the same information and do not have to guess at what needs to be done.
Hope that helps,
Andy