Type or namespace name ‘VisualStudio’ does not exist in the namespace ‘Microsoft’

I got this error when trying to build a project in TFS. These steps fixed it: remove reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework add nuget MSTest.TestFramework add nuget MSTest.TestAdapter (optional but needed to run tests inside Visual Studio) The above steps caused this element to be removed from my .csproj file: <Reference Include=”Microsoft.VisualStudio.QualityTools.UnitTestFramework” /> And these two were … Read more

How to make a namespace alias available only to a class

Namespace alias in the class definition is illegal, as specified by the language specification. Its allowed in only in namespace scope or function scope. You can make an alias at the namespace scope. But this will create a permanent alias which can be used from other files as well. However, the solution is simple: you … Read more

Why do we need both using-directives and include-directives?

using directives and include preprocessor directives are two different things. The include roughly corresponds to the CLASSPATH environment variable of Java, or the -cp option of the java virtual machine. What it does is making the types known to the compiler. Just including <string> for example will make you able to refer to std::string : … Read more

Are there any uses for unnamed namespaces in header files?

The only situation in which a nameless namespace in header can be useful is when you want to distribute code as header files only. For example, a large standalone subset of Boost is purely headers. The token ignore for tuples, mentioned in another answer is one example, the _1, _2 etc. bind placeholders are others.

How can I properly overload the

I am just telling you about one other possibility: I like using friend definitions for that: namespace Math { class Matrix { public: […] friend std::ostream& operator<< (std::ostream& stream, const Matrix& matrix) { […] } }; } The function will be automatically targeted into the surrounding namespace Math (even though its definition appears within the … Read more

How do you correctly define entities within a namespace that have been declared in a header?

From a code readability standpoint, it is probably better in my opinion to use the #2 method for this reason: You can be using multiple namespaces at a time, and any object or function written below that line can belong to any of those namespaces (barring naming conflicts). Wrapping the whole file in a namespace … Read more

How are unnamed namespaces superior to the static keyword? [duplicate]

You’re basically referring to the section ยง7.3.1.1/2 from the C++03 Standard, The use of the static keyword is deprecated when declaring objects in a namespace scope; the unnamed-namespace provides a superior alternative. Note that this paragraph was already removed in C++11. static functions are per standard no longer deprecated! Nonetheless, unnamed namespace‘s are superior to … Read more

What is a namespace alias?

A namespace alias is a convenient way of referring to a long namespace name by a different, shorter name. As an example, say you wanted to use the numeric vectors from Boost’s uBLAS without a using namespace directive. Stating the full namespace every time is cumbersome: boost::numeric::ublas::vector<double> v; Instead, you can define an alias for … Read more

Why should you prefer unnamed namespaces over static functions?

The C++ Standard reads in section 7.3.1.1 Unnamed namespaces, paragraph 2: The use of the static keyword is deprecated when declaring objects in a namespace scope, the unnamed-namespace provides a superior alternative. Static only applies to names of objects, functions, and anonymous unions, not to type declarations. Edit: The decision to deprecate this use of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)