我有以下代码
#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;
}
我需要使用免费功能来显示大约 60 个星号,其中我有 cout << endl。我遵循了我给出的示例,但无法使其正常工作。
下面的代码是我得到的关于自由函数外观的示例。
void companyBanner()
{
cout << *************************** << endl;
cout << ** Tech Guys LLC ** << endl;
cout << *************************** << endl;
cout << endl;
}
更新a:得到它的工作,感谢大家的帮助。我重写了 free 函数并再次在 main 上方添加了 asterisks() 并且它起作用了。一定是自由功能中的某些东西导致它无法工作。