Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.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
语法查询,在Visual C+中调用模块+; 我试图把我的模块化知识应用到Visual C++,但是,在看似无穷无尽的搜索搜索语法的情况下,我就是不能正确地理解。基本上,在这段代码中,一旦用户输入他们的选择(目前为止只有编码选项1)以将该值返回到main,main随后进入if语句并调用fahrenheit,就首先调用菜单。我请求通过引用传递的语法,我知道C的语法,但不知道Visual C++_C++ - Fatal编程技术网

语法查询,在Visual C+中调用模块+; 我试图把我的模块化知识应用到Visual C++,但是,在看似无穷无尽的搜索搜索语法的情况下,我就是不能正确地理解。基本上,在这段代码中,一旦用户输入他们的选择(目前为止只有编码选项1)以将该值返回到main,main随后进入if语句并调用fahrenheit,就首先调用菜单。我请求通过引用传递的语法,我知道C的语法,但不知道Visual C++

语法查询,在Visual C+中调用模块+; 我试图把我的模块化知识应用到Visual C++,但是,在看似无穷无尽的搜索搜索语法的情况下,我就是不能正确地理解。基本上,在这段代码中,一旦用户输入他们的选择(目前为止只有编码选项1)以将该值返回到main,main随后进入if语句并调用fahrenheit,就首先调用菜单。我请求通过引用传递的语法,我知道C的语法,但不知道Visual C++,c++,C++,这是密码 // Test.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string> using namespace std; void Celsius() { } void fahrenheit() { cout << "Success!" <<

这是密码

    // Test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

void Celsius()
{
}

void fahrenheit()
{
    cout << "Success!" << endl; //....Outputs this just to see if the module is being called properly.
}

int menu(int Mystring) //....I was testing this syntax to pass the variable.
{
    cout << "What would you like to do : " << endl;
    cout << "1) Fanreheit to Celsius" << endl;
    cout << "2) Celsius to Fahrenheit" << endl;

    cout << "Choice : " ;

    cin >> Mystring;

    return Mystring;
}

int main()
{
    int celsius = 0;
    int fahrenheit = 0;
    int Mystring = 0;

    menu(Mystring); //....Testing this syntax to pass Mystring to menu.

    if (Mystring == 1) //....I was hoping the menu would return Mystring as value = 1.
    {
        fahrenheit(); //.......I want this to call fahrenheit module if Mystring = 1
    }
}
//Test.cpp:定义控制台应用程序的入口点。
//
#包括“stdafx.h”
#包括
#包括
使用名称空间std;
无效摄氏度()
{
}
真空华氏温度()
{
你说的“东西”不是模块,而是函数。这是一个很大的区别,我想你应该知道,因为没有这些知识,你几乎不会理解任何文章

清除后,代码中的问题是,通过值传递变量(
int-menu(int-Mystring)
),而为了在函数内部更改变量,需要通过引用或指针传递:

int menu(int &Mystring)

《C++》中有很多关于函数的问题。你应该检查一下。< /P>请原谅语法错误。我会尝试语法,我需要添加任何代码来调用调用代码菜单(MyScript)吗?我的导师调用C i中的函数模块,知道两者之间的区别,(按值和参考)是的,使用C中的ref语法。此外,为了扩展,我有华氏温度(Mystring)我刚刚添加了一个Visual C++,它要求函数函数类型的指针。函数的声明<代码>华氏Health/<代码>不带任何参数。如果您想将变量传递给函数,请更改声明。也请实际阅读我在文章中链接的文章,它回答了所有您的问题。请说,给您带来的不便,我深表歉意。