The error:

"cannot declare a class template with no name"

is given by clang++ with the following file, "foo.cpp":

#ifndef foo
#define foo

template <class T>
struct foo {
private:
    const T t;
};

#endif

The command line input and error:

me@computer$ clang++ -c foo.cpp
foo.cpp:5:1: error: cannot declare a class template with no name
有帮助吗?

解决方案

Change the include guards. They define foo to be nothing, replacing any further occurrence of foo with nothng. This removes your class template's name.

#ifndef FOO_H_
#define FOO_H_

// as before

#endif
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top