java - C++ 编译器选择问题
PHP中文网
PHP中文网 2017-04-18 10:51:30
0
3
596

平时用codeblocks,编译时出现这些问题,上网查结果很少,要么跳转要英文网站,请问这是因为这款软件默认GCC编译而提示这样的错误(gcc的特定语法?)还是英文导致搜索结果少(我用百度)

处理这些问题老是半天都找不到解决方法。如果前者,我应该改大众一些的IDE,如vc++;如果后者,我应该改为中文?

应该是前者吧,因为搜索结果老是看到gcc字眼,如果在cb里设置为vc++编程是否错误显示就是vc类型了呢?

附图_原错误代码

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
小葫芦

n is not declared in scope

迷茫

There are three common declaration structures related to function templates: declaring function templates, declaring specializations, and declaring instances.

template <class T, ...>
void foo();

template <>
void foo<T1, T2, ...>(); // 除非是特化含参数包的模板,否则参数列表不能为空

template void foo<T1, T2 ...>(); // 同上

The same thing happens if you replace it with operator overloading

template <class T>
std::ostream &operator<<(std::ostream &, Seqlist<T> &);

template <>
std::ostream &operator<<<int>(std::ostream &, Seqlist<int> &);

template
std::ostream &operator<<<int>(std::ostream &, Seqlist<int> &);

I think you are not specializing here, you just want to declare the template. Because you used template parameters in the function parameter list. Refer to the first way of writing.

If you don’t do too much template development, the overloading of stream’s << is actually this routine, just memorize it. Another common form is

template <class CharT, class Traits>
std::basic_ostream<CharT, Traits> &operator<<(std::basic_ostream<CharT, Traits> &, ??);

I don’t think it’s necessary to change the compiler. I can learn the syntax from the book. If you want to search, you have to search for "ostream overloading writing method" and then compare the codes. If it is a very deep template usage, the copy syntax error message search will not be able to find out the reason.

阿神

The error message the compiler gives you is very clear. Maybe you can’t read English. Don’t worry about which compiler to choose, the compiler is innocent, gcc is pretty good

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template