By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,852 Members | 2,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,852 IT Pros & Developers. It's quick & easy.

How to remove dependency on a header file which has a typedef?

P: n/a
I have a header file say A.h in which I have typedefed

typedef std::vector<std::string> StringVector;

Now there is second file say B.h in which a class B has a method

class B {
....
ParseData(const StringVector::const_iterator& begin, const
StringVector::const_iterator& end);

};

Now without #including A.h in B.h, how can I declare
StringVector::const_iterator properly in B.h. I tried to do a forward
declaration in B.h but I get compilation errors.

// Following gives compilation errors if I put it in B.h
Class StringVector::const_iterator;

Thank you for your replies.

Vikas
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Vikas" <vs*****@hotmail.com> wrote...
I have a header file say A.h in which I have typedefed

typedef std::vector<std::string> StringVector;

Now there is second file say B.h in which a class B has a method

class B {
...
ParseData(const StringVector::const_iterator& begin, const
StringVector::const_iterator& end);
.
};

Now without #including A.h in B.h, how can I declare
StringVector::const_iterator properly in B.h.
Put the typedef in C.h and #include C.h in both A.h and B.h.
I tried to do a forward
declaration in B.h but I get compilation errors.

// Following gives compilation errors if I put it in B.h
Class StringVector::const_iterator;


'Class' is not C++. 'class' would be C++. Although, there is no
forward-declaration of members in C++, anyway.

Victor
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.