Classes with same name in different namespace

throw_away_account

I am writing a library. Is it a bad idea to have two classes with same name but each of the classes are in different namespace?

Using name spaces:

//forward declaration
namespace sparse {
    class matrix;
}
namespace dense {
    class matrix;
}

namespace dense {
    typedef Index uint64_t;
    class matrix {
        public:
        sparse::matrix tosparse();
    };
}

namespace sparse {
    typedef Index uint32_t;
    class matrix {
        dense::matrix todense();
    };
}

Alternatively, I can use long names:

class sparse_matrix
...
Pete Becker

In general, that's fine. That's exactly what namespaces are for. In this example it's not clear what the design goal is, so it's not clear whether this is an appropriate use of namespaces.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Can two classes with the same name be in the same namespace across two different assemblies?

How does CLR differentiate classes with the same name but without namespace in different assemblies at runtime?

XSLT for XML with same namespace name, different URIs

Two objects with the same name in the same namespace in different cpp files

Declaring multiple objects of different classes with the same name

Using classes with same name but different logic

Windows Phone Classes with same name but different folders

Rails and RSpec: Testing controllers with the same name in different namespace (module)

Inheritance for class with the same name but different namespace c++

Java - Two classes, same name, same package but in different folders

Deserialize different xml elements with same name into different C# classes

Swagger different classes in different namespaces with same name don't work

Namespace and class with the same name?

What are implications of namespacing classes under same namespace/under the same name as a module

two classes, same property name, different type -> gets overridden

How can the JPA recognize two classes with the same name but in different packages?

Bad practice to have two classes of the same name in different packages?

Newtonsoft json - deserialize classes with same name, but different properties

How to handle MVC DisplayTemplates for two classes with the same name (different namespaces)

Can't create private classes with same name in different modules

Instance variables with same name in different classes causing compile error

c++ global variables with same name for different classes

Using functions with the same name from different classes; what pattern is this?

How to distinguish classes with the same name defined in different Gems?

ActionScript 3 same symbol different instance name. Classes

Java Templates, how to use two classes with the same name and different types

How to call methods with same name but in different, unrelated classes?

Using different classes (one imported and one defined) with the same name in a module

Is it possible to have PVC's with the same name accross different namespace when using different PV's in Kubernetes?