小编Ste*_*ven的帖子

为什么我得到字符串没有命名类型错误?

game.cpp

#include <iostream>
#include <string>
#include <sstream>
#include "game.h"
#include "board.h"
#include "piece.h"

using namespace std;
Run Code Online (Sandbox Code Playgroud)

game.h

#ifndef GAME_H
#define GAME_H
#include <string>

class Game
{
    private:
        string white;
        string black;
        string title;
    public:
        Game(istream&, ostream&);
        void display(colour, short);
};

#endif
Run Code Online (Sandbox Code Playgroud)

错误是:

game.h:8 error: 'string' does not name a type
game.h:9 error: 'string' does not name a type

c++ string std

64
推荐指数
4
解决办法
22万
查看次数

在C++类中存储指向istream和ostream的指针

game.h

#ifndef GAME_H
#define GAME_H
#include <string>
#include <iostream>
#include "piece.h"

using namespace std;

class Game
{
    private:
        string white;
        string black;
        string title;
        istream* in;
        ostream* out;
    public:
        Game();
        Game(istream&, ostream&);
        void display(Colour, short);
};

#endif
Run Code Online (Sandbox Code Playgroud)

game.cpp

#include <iostream>
#include <string>
#include <sstream>
#include "game.h"
#include "board.h"
#include "piece.h"

using namespace std;

Game::Game()
{
    //nothing
}

Game::Game(istream& is, ostream& os)
{
    in = is;
    out = os;
}

void Game::display(Colour colour, short moves)
{
    //out << "a";
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试在我班级的其他部分使用istream和ostream,但我不能,因为g …

c++

6
推荐指数
1
解决办法
6848
查看次数

删除元素的所有onclick事件

var links = document.body.querySelectorAll("p.sourcelinks a.individual_source_link");
for(var i=0;i<links.length;i++)
{
    links[i].onclick = null;
}
Run Code Online (Sandbox Code Playgroud)

是我当前的代码,但它不会删除onclick事件.我不知道它们会是什么,因为这是一个油脂脚本.

javascript greasemonkey

3
推荐指数
2
解决办法
2万
查看次数

在Javascript中排序

我想按时间排序.这是我的尝试:

var days = new Array();
var days['SU'] = 0;
var days['MO'] = 1;
var days['TU'] = 2;
var days['WE'] = 3;
var days['TH'] = 4;
var days['FR'] = 5;
var days['SA'] = 6;

events.sort(function(a, b)
{
    if(a['day'] != b['day'])
    {
        return (days[a['day']] < days[b['day']]) ? 1 : -1;
    }
    else if(a['time'] != b['time'])
    {
        return (a['time'] < a['time']) ? 1 : -1;
    }
    else
        return 0;
);
Run Code Online (Sandbox Code Playgroud)

它没有经过测试,但我做得对吗?(时间asc,天asc)星期一早上8点,星期二上午8点,星期一晚上9点是我正在寻找的订单.

干杯.

events[0]['day'] = 'MO';
events[0]['time'] = 8;
events[1]['day'] = 'MO';
events[1]['time'] …
Run Code Online (Sandbox Code Playgroud)

javascript sorting

2
推荐指数
1
解决办法
189
查看次数

Matrix(row,col)= value

double Matrix::operator()(unsigned int a, unsigned int b)
{
    return m[a*rows+b];
}
Run Code Online (Sandbox Code Playgroud)

我现在有以上用于访问存储在矩阵中的值,但是我希望能够在该位置设置值.那可能吗?

c++ matrix

0
推荐指数
1
解决办法
1163
查看次数

标签 统计

c++ ×3

javascript ×2

greasemonkey ×1

matrix ×1

sorting ×1

std ×1

string ×1