错误 C2660:'SurroundTheGrid':函数不接受 0 个参数
error C2660: 'SurroundTheGrid' : function does not take 0 arguments
请帮助,有问题,试图测试我的编程任务为c++。任何帮助将不胜感激,我认为这与我在一个名为SurroundTheGrid()的函数中的参数有关
1>------ Build started: Project: Assignment 08 ADL, Configuration: Debug Win32 ------
1>Build started 3/19/2013 12:57:34 PM.
1>InitializeBuildStatus:
1> Creating "DebugAssignment 08 ADL.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> Assignment 08 ADL.cpp
1>j:co 127assignment 08 adlassignment 08 adl.cpp(108): error C2660: 'SurroundTheGrid' : function does not take 0 arguments
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:12.90
========== 构建:0成功,1失败,最新的,0跳过 ==========
很抱歉没有发布代码,我是新手。但这里是任何帮助将是非常感激的,谢谢你。
/*
Anthony Lehnen
Assignment 08 ADL
03/12/2013
*/
#include <iostream>
#include <string>
#include "student.h" // this includs student.h
#include "COMPFUN.H" // for decimals
#include "GRID.H"
extern const int east = 3;
using namespace std;
//************HEADER**************//
void Heading()
{
system("cls");
cout << "Anthony Lehnent" "CO 127t" "02/28/2013t" "Assignment 07" << endl;
cout << endl;
cout << endl;
}
void display(student aStudent)
{
decimals(cout, 2);
cout << "{ student: " << aStudent.name();
cout << ", GPA = " << aStudent.GPA() << " }" << endl;
}
int Student()
{ // test drive student: this main will vary amongst students
student aStudent("Nguyen", 36.5, 123.5);
student anotherStudent("Stella", 4.0, 16.0); // Straight A so far
student one("one", 0.0, 0.0); // Should be 3.0
one.completedCourse( 4.0, 2.0 );
one.completedCourse( 4.0, 4.0 ); // 4 credit A
display(one);
display(aStudent);
display(anotherStudent);
// Finish branch coverage testing of standing
student two("two", 100.0, 30.0);
student three( "three", 30.05, 100.0 );
student four("four" , 60.0, 100.0 );
student five("five ", 60.05, 100.0);
student six ("six " , 90.0, 100.0);
student seven("seven", 90.05, 100.0 );
cout << endl << endl;
cout << "Student: " << one.name() <<" is a " << one.standing() << endl;
cout << "Student: " << two.name() <<" is a " << two.standing() << endl;
cout << "Student: " << three.name() <<" is a " << three.standing() << endl;
cout << "Student: " << four.name() <<" is a " << four.standing() << endl;
cout << "Student: " << five.name() <<" is a " << five.standing() << endl;
cout << "Student: " << six.name() <<" is a " << six.standing() << endl;
cout << "Student: " << seven.name() <<" is a " << seven.standing() << endl;
cout << endl << endl;
return 0;
}
void SurroundTheGrid()
{
int r, c;
for(r = 0; r < g.nRows(); r++)
{
myGrid.putDown(r, 0);
myGrid.putDown(r, myGrid.nColumns()-1);
}
for(c = 1; c < myGrid.nColumns() -1; c++)
{
myGrid.putDown(0, c);
myGrid.putDown(myGrid.nRows()-1, c);
}
}
int TestSurroundGrid()
{//Test drive SurroundTheGrid
grid myGrid(4, 10, 3, 0, east);
SurroundTheGrid(myGrid);
myGrid.display();
return 0;
}
//**********************MAIN***************************//
int main()
{
Heading();
Student();
system("pause");
system("CLS");
Heading();
SurroundTheGrid();
system("pause");
return 0;
}
从编译器读取错误消息是一项重要的技能,所以让我们看看我们能从中得到什么。你得到的具体错误是这个:
j:co 127assignment 08 adlassignment 08 adl.cpp(108): error C2660: 'SurroundTheGrid' : function does not take 0 arguments
正如你已经正确解释的那样,它说问题与你的SurroundTheGrid
函数有关。但是,它不是函数本身的声明或定义。问题实际上是在你的一个调用函数。
具体来说,错误消息告诉您问题位于文件assignment 08 adl.cpp
的第108行附近(尽管它给了您完整的路径,只是为了使消息更长)。
它告诉你,你试图调用SurroundTheGrid
函数没有参数,但它实际上需要一些参数(我不知道确切的数字,错误消息没有说)。
大概,在第108行发生的事情是这样的:
SurroundTheGrid(); // passes no arguments to the function -- WRONG!
当你应该这样写的时候:
SurroundTheGrid(myGrid); // pass an argument specifying the grid (or something)
由于您没有发布代码,所以我不能在这里详细说明,但您的猜测是对的。就像错误状态一样,您用0个参数调用函数SurroundTheGrid
(所以只是括号,没有任何参数),但是函数不接受0个参数。这意味着您应该提供正确的参数数量和类型(同样,我不能告诉您有多少或什么参数,因为您没有发布您的代码)。
相关文章:
- 函数不接受 X 参数,函数使用默认参数
- 为什么不接受具有默认分配参数的函数作为 0-arg 生成器?
- 函数不接受 C++ 参数
- SQLHANDLE-Parameters:函数不接受x个参数(但实际上确实如此)
- 函数不接受 1 个参数
- 为什么析构函数不接受C++中的参数?
- 为什么C++可变参数模板不接受 iostream 值作为参数?
- C++:将引用作为参数传递,但该函数不接受引用作为参数
- 我的构造函数方法不接受参数(DirectX / Windows)
- 可变参数模板化构造函数不接受 x 参数
- 为什么 std::is_invocable 不接受非类型模板参数
- 错误 C2660:'MouseListener::MousePressed':函数不接受 4 个参数
- 不接受静态成员函数作为 constexpr 参数
- 方法指针映射,编译器说他们不接受任何参数
- GCC 不接受默认模板参数中的包扩展
- 为什么Clang和VS2013接受移动大括号初始化的默认参数,而不接受GCC 4.8或4.9
- C++ 中的特征库给出错误 C2660:"特征::矩阵基<Derived>::特征值":函数不接受 2 个参数
- strtrok_s函数不接受2个参数
- 函数不接受一个参数
- 带有 const 参数的方法不接受非 const 参数