Home  >  Q&A  >  body text

java - C++ 编译器选择问题

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

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

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

附图_原错误代码

PHP中文网PHP中文网2743 days ago556

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-04-18 10:53:30

    n is not declared in scope

    reply
    0
  • 迷茫

    迷茫2017-04-18 10:53:30

    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.

    reply
    0
  • 阿神

    阿神2017-04-18 10:53:30

    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

    reply
    0
  • Cancelreply