C++ I';我试图在另一个函数中调用void函数,但我不';我不知道如何正确放置它们 #包括 #包括 #包括 #包括 #包括 使用名称空间std; //这些应该有我声明的所有函数 int开始(字符x、字符y、字符z); void-pim(); void pmm(); 无效登录(); void createa(); //我的作业要求我只使用一个函数 int main() { 开始(pim()、登录()、创建A()); 返回0; } //这应该是代码的开始 无效pim() { cout

C++ I';我试图在另一个函数中调用void函数,但我不';我不知道如何正确放置它们 #包括 #包括 #包括 #包括 #包括 使用名称空间std; //这些应该有我声明的所有函数 int开始(字符x、字符y、字符z); void-pim(); void pmm(); 无效登录(); void createa(); //我的作业要求我只使用一个函数 int main() { 开始(pim()、登录()、创建A()); 返回0; } //这应该是代码的开始 无效pim() { cout,c++,C++,我想你要找的是函数指针,例如: #include <iostream> #include <fstream> #include <iomanip> #include <string> #include <cmath> using namespace std; // these should have all of my declared functions int start(char x, char y, char z); vo

我想你要找的是函数指针,例如:

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>

using namespace std;

// these should have all of my declared functions

int start(char x, char y, char z);
void pim();
void pmm();
void login();
void createa();

//my assignment wants me to have only one function used

int main()
{
    start(pim(), login(), createa());

    return 0;
}

//This should be the start of the code

void pim()
{
    cout << "Please select a letter from the menu below:" << endl;
    cout << "l - Login" << endl;
    cout << "c - Create New Account" << endl;
    cout << "q - Quit" << endl;
}

// this is to post a menu after you make the first choice above

void pmm()
{
    cout << "d - Deposit Money" << endl;
    cout << "w - Withdraw Money" << endl;
    cout << "r - Request Balance" << endl;
    cout << "q - Quit" << endl;
}

//this is to login to the account

void login()
{
    cout << "Okay, you're in" << endl;
}

// this is to create an account

void createa()
{
    int id = 0;
    int password = 0;

    cout << "create an ID of two numbers" << endl;
    cin >> id;

    cout << "Make a password of 4 numbers" << endl;
    cin >> password;
}

// Starts and is basically the entire project

int start(char x, char y, char z)
{
    char pim = x;
    cout << pim;

    int choice = 0;
    char select = '\0';

    cout << "Enter the choice that you want:";
    cin >> choice;

    if(select == 'l')
    {
        choice = 1;  
    }
    else if( select == 'c')
    {
        choice = 2;
    }
    else
    {
        choice = 3;
    }

    switch (choice)
    {
        case 1:
            cout << y << endl;
            break;
        case 2:
            cout << z << endl;
            break;
        case 3:
            exit(0);
            break;
        default:
            cout << "This is not a command" << endl;
    }

    return 0;

}
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
//这些应该有我声明的所有函数
int开始(void(*x)(),void(*y)(),void(*z)();
void-pim();
void pmm();
无效登录();
void createa();
//我的作业要求我只使用一个函数
int main()
{
启动(&pim,&login,&createa);
返回0;
}
//这应该是代码的开始
无效pim()
{

有什么问题吗?
start(pim(),login(),createa());
没有意义,因为函数是
void
。您了解从函数返回值的方法吗?这似乎是您想要做的。函数参数也不能保证从左到右求值。这三个函数可以按任意顺序执行。我想您要找的是函数指针
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>

using namespace std;

// these should have all of my declared functions

int start(void (*x)(), void (*y)(), void (*z)());
void pim();
void pmm();
void login();
void createa();

//my assignment wants me to have only one function used

int main()
{
    start(&pim, &login, &createa);

    return 0;
}

//This should be the start of the code

void pim()
{
    cout << "Please select a letter from the menu below:" << endl;
    cout << "l - Login" << endl;
    cout << "c - Create New Account" << endl;
    cout << "q - Quit" << endl;
}

// this is to post a menu after you make the first choice above

void pmm()
{
    cout << "d - Deposit Money" << endl;
    cout << "w - Withdraw Money" << endl;
    cout << "r - Request Balance" << endl;
    cout << "q - Quit" << endl;
}

//this is to login to the account

void login()
{
    cout << "Okay, you're in" << endl;
}

// this is to create an account

void createa()
{
    int id = 0;
    int password = 0;

    cout << "create an ID of two numbers" << endl;
    cin >> id;

    cout << "Make a password of 4 numbers" << endl;
    cin >> password;
}

// Starts and is basically the entire project

int start(void (*x)(), void (*y)(), void (*z)())
{
    x();

    char choice = '\0';

    cout << "Enter the choice that you want:";
    cin >> choice;

    switch (choice)
    {
        case 'l':
            y();
            break;
        case 'c':
            z();
            break;
        case 'q':
            exit(0);
            break;
        default:
            cout << "This is not a command" << endl;
    }

    return 0;
}
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>

using namespace std;

// these should have all of my declared functions

int start();
void pim();
void pmm();
void login();
void createa();

//my assignment wants me to have only one function used

int main()
{
    start();

    return 0;
}

//This should be the start of the code

void pim()
{
    cout << "Please select a letter from the menu below:" << endl;
    cout << "l - Login" << endl;
    cout << "c - Create New Account" << endl;
    cout << "q - Quit" << endl;
}

// this is to post a menu after you make the first choice above

void pmm()
{
    cout << "d - Deposit Money" << endl;
    cout << "w - Withdraw Money" << endl;
    cout << "r - Request Balance" << endl;
    cout << "q - Quit" << endl;
}

//this is to login to the account

void login()
{
    cout << "Okay, you're in" << endl;
}

// this is to create an account

void createa()
{
    int id = 0;
    int password = 0;

    cout << "create an ID of two numbers" << endl;
    cin >> id;

    cout << "Make a password of 4 numbers" << endl;
    cin >> password;
}

// Starts and is basically the entire project

int start()
{
    pim();

    char choice = '\0';

    cout << "Enter the choice that you want:";
    cin >> choice;

    switch (choice)
    {
        case 'l':
            login();
            break;
        case 'c':
            createa();
            break;
        case 'q':
            exit(0);
            break;
        default:
            cout << "This is not a command" << endl;
    }

    return 0;
}