Skip to main content
GameDev.net gamedev.net
🔒 Locked

[C++] Evading naming conflicts

Started by HopeDagger Dec 25, 2006 at 11:34 PM 6 replies 2.2k views
Original Post
HopeDagger
HopeDagger
I'm writing a program that makes use of a Curses library, which defines a clear() function amongst many others. However, I'm also using the STL 'string' class, which defines a method clear() as well. Unfortunately, these two are conflicting. Is there any way around this? Thanks in advance!
jflanglois
jflanglois
Quote:
Original post by HopeDagger
I'm writing a program that makes use of a Curses library, which defines a clear() function amongst many others. However, I'm also using the STL 'string' class, which defines a method clear() as well. Unfortunately, these two are conflicting. Is there any way around this?

Thanks in advance!


Can you post the specific error(s) you are getting? And possibly some offending code?


jfl.
Smit
Smit
Do you have 'using namespace std'? If you do lose it and just prefix STL class with std::
Vorpy
Vorpy
How is a method name conflicting with a function name? Class members are in a separate namespace associated with the class. Unless this curses library is defining clear with a macro...
Bimble Bob
Bimble Bob
Quote:
Original post by Smit
Do you have 'using namespace std'? If you do lose it and just prefix STL class with std::


You don't have to loose it. You can just use std:: anyway to solve ambiguity.
It's not a bug... it's a feature!
Zakwayda
Zakwayda
It looks like the problem is that the Curses library defines clear() as a macro. Here is a link that discusses the problem and some possible solutions.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.