質問

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