Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;代码问题_C++ - Fatal编程技术网

C++ C++;代码问题

C++ C++;代码问题,c++,C++,我对此代码有一些问题。我试图展示。。。 12345 12345 12345 但我得到一个错误,说 错误1错误C3861:“displayOneRowOfDesign1”:找不到标识符 有人能帮忙吗 // displays (on the screen) design1 void displayDesign1 () { system ("cls"); // clears the screen // the entire for loop displays all three rows

我对此代码有一些问题。我试图展示。。。 12345 12345 12345

但我得到一个错误,说

错误1错误C3861:“displayOneRowOfDesign1”:找不到标识符

有人能帮忙吗

// displays (on the screen) design1 
void displayDesign1 ()
{
  system ("cls"); // clears the screen

  // the entire for loop displays all three rows 
  for (int r = 1; r <= 3; r++)
  { // One iteration of the body of this loop displays row number r.
    // In other words, when r is 1, row 1 is displayed; 
    //                 when r is 2, row 2 is displayed; ...
    displayOneRowOfDesign1 ();
  }

} // displayDesign1  


// displays one row of design1; helper function to displayDesign1 
void displayOneRowOfDesign1 ()
{
  // the entire for loop displays all the columns of the row
  for (int c=1; c <= 5; c++)
  { // One iteration of this loop displays the symbol in column c
    // In other is case, when c is 1, a 1 is displayed; 
    //                   when c is 2, a 2 is displayed; ...
    cout << c;
  }

  cout << endl; // wraps up the row 
                // by sending the cursor to the next row (line)

} // displayOneRowOfDesign1  
//显示(屏幕上)设计1
void displayDesign1()
{
系统(“cls”);//清除屏幕
//整个for循环显示所有三行

对于(int r=1;rC++是相当老式的,在使用之前需要了解一些东西。剪切并粘贴displayOneRowOfDesign1,使其位于第一个函数之上。

尝试添加

void displayOneRowOfDesign1();

到代码顶部。这称为“转发声明”并且是必需的,因为您试图在定义该函数之前调用它。

编译器自上而下读取代码;在解析调用
displayOneRowOfDesign1的
displayOneRowOfDesign1
时,它不知道
displayOneRowOfDesign1
存在

displayOneRowOfDesign1
移到
displayDesign1
上方,或将置于函数定义之前的顶部(您可以将其视为对编译器的承诺,即稍后将定义具有该签名的函数):


C++使用单遍编译器。是的,1。如果这些函数是类定义的成员,它就不会是问题,但是你的代码呈现的方式看起来像是独立的函数。如果是这样的话,那么,你需要用和变量一样的方式定义/使用它们。现在我有了这个,我又得到了一个错误。ng…错误1错误LNK2019:未解析的外部符号\u main在函数中引用\uuuuu tmaincrtstupts这在不知道您的设置的情况下有点难以调试。您是否使用Visual Studio?如果是,这应该是一个控制台应用程序吗?是的,我使用Visual Studio,是的,它应该是一个控制台应用程序。您必须有两件事:首先,您必须定义一个main()函数,然后在“项目设置”下,您需要将类型设置为控制台应用程序。我不记得此设置的确切位置,它可能是链接器设置。
void displayOneRowOfDesign1();

// Your function definitions...