Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;在vs代码中出错时使用haskell编译器编程_C++_Visual Studio Code_Cross Compiling - Fatal编程技术网

C++ C++;在vs代码中出错时使用haskell编译器编程

C++ C++;在vs代码中出错时使用haskell编译器编程,c++,visual-studio-code,cross-compiling,C++,Visual Studio Code,Cross Compiling,当我有以下代码时: #include <iostream> #include <queue> using namespace std; struct Card { enum suit {CLUBS, DIAMONDS, HEARTS, SPADES}; suit Suit; int rank; }; class Deck { queue<Card> deck; public: //create the dec

当我有以下代码时:

#include <iostream>
#include <queue>

using namespace std;

struct Card
{
    enum suit {CLUBS, DIAMONDS, HEARTS, SPADES};
    suit Suit;
    int rank; 
};

class Deck 
{
    queue<Card> deck;

public:
    //create the deck of cards
    for(int i = 0; i <= 4; i++) 
    {
        for(int j = 0; j <= 13; j++)
        {
            Card temp = {i, j}
        }
    }
};


int main()
{
    std::cout < "Hello\n";

}
#包括
#包括
使用名称空间std;
结构卡
{
enum套装{梅花、钻石、红桃、黑桃};
西服;
整数秩;
};
甲板
{
队列甲板;
公众:
//创建一副牌

对于(int i=0;i),它是C++编译器,而不是哈斯克尔。 正如其他人在注释中指出的,您不能在类定义中放入for循环(或任何可执行代码)

让我们试着理解第二条错误消息:

main.cpp: In function 'int main()':
main.cpp:31:15: error: no match for 'operator<' (operand types are 
'std::ostream {aka std::basic_ostream<char>}' and 'const char [7]')
     std::cout < "Hello\n";
     ~~~~~~~~~~^~~~~~~~~~~
编译器认为也许你是想打电话给他们,你知道也许你打错了什么。编译器还告诉你他们在哪里:

C:/Program Files/Haskell 
Platform/8.2.2/mingw/include/c++/6.2.0/bits/stl_pair.h:369:5: note: 
消息的中间部分还告诉您编译器是如何找到它们的,因为它们包含在您的
main.cpp
到:(自下而上读取)

这些文件位于Haskell目录中,仅此而已


< C++中的错误消息有时很长(特别是用模板),但是如果你仔细地阅读它们,你应该总是有足够的信息来修复你的代码,或者至少看到问题在哪里。

你不能在C++类的中间编写代码。也许你想要一个代码>甲板< /C>构造器。(为什么这是标签哈斯克尔?)在得到了缺失的函数位后,我建议检查这里允许的值[Cux>(int i=0);我看起来像C++编译器。它只是说文件中有一个错误发生在Haskell目录中。为什么它们把这些文件放在那里是不相关的。错误实际上在代码中。(
std::cout
应该是
std::cout基本上,你说你想比较
std::cout
,它是
std::ostream
对象和
char*
(字符串)因此编译器继续搜索与该描述匹配的运算符。错误的第二行表示未找到任何运算符。但同时指出有两个
std::operator@Quimby在这一点上,你已经把这两条评论放在了一起,得到了一个合理且信息丰富的答案。不妨正式地写下来向上的
main.cpp: In function 'int main()':
main.cpp:31:15: error: no match for 'operator<' (operand types are 
'std::ostream {aka std::basic_ostream<char>}' and 'const char [7]')
     std::cout < "Hello\n";
     ~~~~~~~~~~^~~~~~~~~~~
template<class _T1, class _T2> constexpr bool 
std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
C:/Program Files/Haskell 
Platform/8.2.2/mingw/include/c++/6.2.0/bits/stl_pair.h:369:5: note: 
In file included from C:/Program Files/Haskell 
Platform/8.2.2/mingw/include/c++/6.2.0/bits/stl_algobase.h:64:0,
                 from C:/Program Files/Haskell 
Platform/8.2.2/mingw/include/c++/6.2.0/bits/char_traits.h:39,
                 from C:/Program Files/Haskell 
Platform/8.2.2/mingw/include/c++/6.2.0/ios:40,
                 from C:/Program Files/Haskell 
Platform/8.2.2/mingw/include/c++/6.2.0/ostream:38,
                 from C:/Program Files/Haskell 
Platform/8.2.2/mingw/include/c++/6.2.0/iostream:39,