czy jest jakiś sposób żeby funkcja_52 robiła to samo co funkcja_12 czyli pobierała kilka danych z funkcji pośredniczącej w której w zależności od flag dane się zmieniają w różnych miejscach programu przykładowy program:
#include "stdafx.h"
#include "iostream"
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <conio.h>
#include <iostream>
#include <windows.h>
using namespace std;
//////////////////////////////
//////////////////////////////
void funkcja_11(int &a,int &b,int &c);
void funkcja_12(void (*wskaznik_na_funkcje)(int&,int&,int&),int &a1,int &b1,int &c1);
//////////////////////////////
void funkcja_51(int &a,int &b,int &c);
void funkcja_52(void (*wskaznik_na_funkcje)(int&,int&,int&));
//////////////////////////////
int _tmain(int argc, _TCHAR* argv[])
{
int nowy_nr1=2,nowy_nr2=5,nowy_nr3=7;
cout<<"stary_nr1="<<nowy_nr1<<" stary_nr2="<<nowy_nr2<<" stary_nr3="<<nowy_nr3<<endl;
funkcja_12(funkcja_11,nowy_nr1,nowy_nr2,nowy_nr3);
cout<<"nowy_nr1="<<nowy_nr1<<" nowy_nr2="<<nowy_nr2<<" nowy_nr3="<<nowy_nr3<<endl;
cout<<"koniec testu 1 z 2 "<<endl;
system("pause");
int nr1=10,nr2=12,nr3=14;
cout<<"nr1="<<nr1<<" nr2="<<nr2<<" nr3="<<nr3<<endl;
funkcja_51(nr1,nr2,nr3);
funkcja_52(funkcja_51);
cout<<"koniec testu 2 z 2 "<<endl;
system("pause");
return 0;
}//int _tmain
//////////////////////////////
void funkcja_11(int &a,int &b,int &c)
{
a=a+5;
b=b-2;
c=c+3;
}
//////////////////////////////
void funkcja_12(void (*wskaznik_na_funkcje)(int&,int&,int&),int &a1,int &b1,int &c1)
{
(*wskaznik_na_funkcje)(a1,b1,c1);
}
//////////////////////////////
void funkcja_51(int &a,int &b,int &c)
{
cout<<"przechowywalnia"<<endl;
cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;
}
//////////////////////////////
void funkcja_52(void (*wskaznik_na_funkcje)(int&,int&,int&))
{
int pobrany_nr1=0,pobrany_nr2=0,pobrany_nr3=0;
(*wskaznik_na_funkcje)(pobrany_nr1,pobrany_nr2,pobrany_nr3);
cout<<"pobrany_nr1="<<pobrany_nr1<<" pobrany_nr2="<<pobrany_nr2<<" pobrany_nr3="<<pobrany_nr3<<endl;
}