Before I begin, let me start by saying that this is NOT homework. I am also not enrolled in a C++ class. I am simply trying to learn C++ as I have time. I am using random assigments/tutorials/whatever I can find on the net and shopping amazon for books. I'm not trying to become an awesome programmer, just trying to get a grasp on basic concepts (I'm a network admin and work with a bunch of programmers and just want to be able to understand things better)
I wrote the program at the bottom to understand how classes work and would like to stick with this to understand overloading operators since I understand how this works.
Can someone show me what this program would look like with the following (or if I have typed something stupid in the following, ask me and I'll try to explain what I mean unless I am totally confusing myself):
constructor methods that initialize my variables
program modified with an overloaded (<<) output method that uses friend
program modified with an overloaded (+) method as a class member
program modified with an overloaded (+) method as a function outside of class
Here's the code, and sorry if this is something really easy, I'm just trying to wrap my head around it:
#include <iostream>
using namespace std;
class Statistics
{
private:
int count;
float num, total, average;
public:
void calcAverage()
{
total = 0.0;
int limit = 10;
for (count = 0; count < limit; count++)
{
cout << "Enter a number: ";
cin >> num;
total = total + num;
}
average = total / count;
cout << endl << endl << "AVERAGE: " << average << endl;
}
};
int main()
{
Statistics sp;
sp.calcAverage();
return 0;
}