1

I am having 2 header (.hh) files and there are some functions defined and implemented in both of these files:

What I want it so call a function of the other header file (let's call it B) from an implementation in header file A.

Here is what I have:

//headerA.hh LSQUnit<Impl>::read(...args....) ... callfunction(...args...); } 

where the implementation of call function is in the other header file like this:

// headerB.hh template<class Impl> inline void BaseDynInst<Impl>::callfunction (...args...){ .... } 

I have added in my headerA.hh these:

#include "headerB.hh" .... void call function (...args...) 

but I get undefined reference to callfunction in my headerA.hh

I have also tried these:

when I call it from headerA.hh

callfunction<BaseDynInst> callfunction (...args...) 

or add this impleentation of this in my headerB.hh:

LSQUnit<Impl>::callfunction(...args...) 

but they gave me more errors.

I know that putting implementations inside .hh may not be ideal but I am using a simulator which is not created by me, so I cannot change that because it will make things worse.

Is it possible what I want or the only solution is to implement the function inside headerA.hh ? I want to avoid that because it calls many others that all exist in headerB.hh?

1
  • 1
    If you're using templates, then putting implementations inside the header files is mandatory. Commented Apr 30, 2013 at 15:08

1 Answer 1

2

It seems callFunction is a non-static member function of a template class. the corect way to call it is

LSQUnit<Impl> something; something.callFunction(...); 

That means you need an object of the class type which owns callFunction. In this case something.


This syntax

LSQUnit<Impl>::callfunction(...args...) 

is for calling static member functions.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.