如何有两个函数调用对方C ++ [英] How to have two functions that call each other C++

查看:149
本文介绍了如何有两个函数调用对方C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个这样的函数,对if循环进行模糊处理:

I have 2 functions like this that does obfuscation on if loop:

void funcA(string str)
{
    size_t f = str.find("if");
    if(f!=string::npos)
    {
        funcB(str);        //obfuscate if-loop
    }
}

void funcB(string str)
{
     //obfuscate if loop
     funcA(body_of_if_loop);     //to check if there is a nested if-loop
}

如果我插入 funcB,则 funcA 将无法看到 funcB

The problem with this would be that funcA would not be able to see funcB and vice versa if I put funcB before funcA.

Would appreciate any help or advice here.

推荐答案

您想要的是转发声明

void funcB(string str);

void funcA(string str)
{
    size_t f = str.find("if");
    if(f!=string::npos)
    {
        funcB(str);        //obfuscate if-loop
    }
}

void funcB(string str)
{
     //obfuscate if loop
     funcA(body_of_if_loop);     //to check if there is a nested if-loop
}

这篇关于如何有两个函数调用对方C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆