-1

I have the following code

#include "stdafx.h"
#include <iostream> 
using namespace std;
#include "graderec.h"

int main( )
{
    GradeRecord studentAnn("45-2791", 14, 49);
    GradeRecord studentBob("67-5803",25, 50);

    int bobsUnits;
    int bobsGradePoints;
    int annsUnits = 4;
    int annsGradePoints = 16;

    cout << "Ann's Grade Information:" << endl;
    studentAnn.writeGradeInfo();

    cout << endl;

    cout << "Bob's Grade Information:" << endl;
    studentBob.writeGradeInfo();

    cout << endl;

    cout << "Enter Bob's units: ";
    cin >> bobsUnits;

    cout << "Enter Bob's grade points: ";
    cin >> bobsGradePoints;

    cout << endl;

    cout << "Bob's Grade Information:" << endl;
    studentBob.updateGradeInfo(bobsUnits, bobsGradePoints);
    studentBob.writeGradeInfo();

    cout << endl;

    cout << "Ann's Grade Information:" << endl;
    studentAnn.updateGradeInfo(annsUnits, annsGradePoints);
    studentAnn.writeGradeInfo();

    system("PAUSE");
    return 0;

}

void asterisks()
{ 
    cout << "************************************************************************" << endl;

} 

I need to use a free function to display about 60 asterisks where I have cout << endl. I followed the example that I was giving but can't get it to work.

The code below is the example that I was given on how a free function looks.

void companyBanner()
{
  cout << *************************** << endl;
  cout << **     Tech Guys LLC     ** << endl;
  cout << *************************** << endl; 
  cout << endl;
}

Updatea: Got it working, thanks for the help everyone. I rewrote the free function and added asterisks() above the main again and it worked. Must have been something in the free function that was causing it to not work.

Jacob
  • 21
  • 6

3 Answers3

0

You should call the function you defined otherwise it will never be executed.

You should also place either a declaration or the whole definition of the function before you call it for the first time.

String literals should be enclosed in double quotes ".

Ivaylo Strandjev
  • 64,309
  • 15
  • 111
  • 164
0

'Doesn't work' is too vague for us to help you. My attempt for now is that you have not prototyped your asterisks() function. Put void asterisks(); above your main.

MadPidgeon
  • 85
  • 7
0

If I understand the question (please tell me if I'm wrong), just replace cout << endl; by a call to your function: asterisks().

Also, either move the function asterisks before your main, or add the prototype void asterisks(); above the main.

Maxime Chéramy
  • 14,912
  • 7
  • 43
  • 67