There is a c++ file called main.cpp.
main.cpp
#include "addition.h"
#include <iostream>
int main(){
int x=2;
int y=3;
std::cout<<getsum(x,y);
}
This file includes custom header file called addition.h
addition.h
#include "my_adders.h"
namespace{
int getsum(int a,int b){
return calculate_addition_h(a,b);
}
}
my_adders.h
#include <maths.h>
int calculate_addition_h(int p, int q){
int sum=0;
//Fn definitions
return sum;
}
In main.cpp, i need to override the definition of calculate_addition_h function.
Is it possible?
I tried copying calculate_addition_h definition as well as declaration in main.cpp. However, when, i printed the o/p, calculate_addition_h method in my_adders.h was invoked, not the one in main.cpp.
Please note: I cannot make any changes to addition.h or my_adders.h.
Any help is appreciated!