Results 1 to 8 of 8

Thread: How to compile a project with two classes with same name in different namespaces?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    769
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 94 Times in 86 Posts

    Default Re: How to compile a project with two classes with same name in different namespaces?

    If you've sequestered your classes within different namespaces, you won't get any name collisions unless you've managed to do something wrong. The most common error is excessive or inappropriate use of the 'using' statement, which can strip off namespaces completely and undo the protection they offer. Please post the offending code and the error messages you're receiving.

    Also, I agree with tbscope: it looks like you're trying to emulate Java, rather than use good coding practices. Excessive namespace depth is not necessary in C++ and only serves to make code harder to read. If you need to organize classes, do so with libraries. If you're getting name collisions within your own project, that's a design problem, not a namespace problem.

  2. #2
    Join Date
    Apr 2010
    Posts
    34
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 5 Times in 5 Posts

    Default Re: How to compile a project with two classes with same name in different namespaces?

    Excessive namespace depth is not necessary in C++ and only serves to make code harder to read
    I'd disagree with you, use of namespaces is absolutely clear in C++. Sometimes you just need to give the classes same names. And sometimes you use other's code and there's no chance to "rename" it for your use. And, also, if you deliver a code to somebody, they would like to keep a chance to give their classes any names.

Similar Threads

  1. Project suddenly doesn't compile
    By vieraci in forum Qt Programming
    Replies: 16
    Last Post: 7th June 2016, 07:12
  2. help,who could help me to compile qt project
    By derekli in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2014, 15:27
  3. Replies: 7
    Last Post: 6th May 2010, 09:52
  4. Project compile problems
    By MarkoSan in forum Qt Programming
    Replies: 7
    Last Post: 15th October 2009, 12:54
  5. qmake: add to project but do not compile
    By jesse in forum Newbie
    Replies: 2
    Last Post: 8th November 2007, 16:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.