2013-03-19 67 views
-4

请帮忙,在尝试测试我的C++编程任务时遇到问题。任何帮助将不胜感激,我想它是与我的论点在一个名为SurroundTheGrid()的函数错误C2660:'SurroundTheGrid':函数不需要0个参数

1>------ Build started: Project: Assignment 08 ADL, Configuration: Debug Win32 ------ 
1>Build started 3/19/2013 12:57:34 PM. 
1>InitializeBuildStatus: 
1> Creating "Debug\Assignment 08 ADL.unsuccessfulbuild" because "AlwaysCreate" was specified. 
1>ClCompile: 
1> Assignment 08 ADL.cpp 
1>j:\co 127\assignment 08 adl\assignment 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最新,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 Lehnen\t" "CO 127\t" "02/28/2013\t" "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; 
} 
+5

我期待在我的魔晶球......和我看到......一个函数......是一个带有一些参数的函数......但调用者没有使用参数来调用它......就好像它是某种......学生甚至没有发布他的代码的努力,并希望人们花时间自由思考。 -1,对不起。 – 2013-03-19 17:05:44

+0

发布你的代码,这样我们可以确切地告诉你你的问题是什么。第108行(发生错误的位置)的代码以及“SurroundTheGrid”函数的定义是最重要的,如果您的代码太长而无法完全发布。 – JSQuareD 2013-03-19 17:06:54

+1

添加了代码,对不起大家,新来这个。 – user2035780 2013-03-19 17:21:07

回答

3

从编译器读取错误消息是一项重要的技能,所以我们来看看我们可以从中得到什么。你得到特定的错误是这一个:

j:\co 127\assignment 08 adl\assignment 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

因为您没有发布您的代码,所以我不能在这里详细讨论,但您的猜测是正确的。就像错误状态一样,你使用0个参数调用函数SurroundTheGrid(所以只是括号,没有任何参数),但函数不接受0个参数。这意味着你应该提供正确的数量和类型的参数(再次,我不能告诉你多少或什么参数,因为你没有发布你的代码)。

相关问题