标准库的C ++问题

时间:2019-02-26 16:41:36

标签: c++ class std

我之所以写这篇文章,是因为我一生中第一次遇到了Visual Studio Community 2017难以理解的错误:

除了在main.cpp中,我根本不能在所有类中使用std的其他成员,然后使用“ nullptr_t”。 当在main.cpp中编写“ std ::”时,视觉效果的自动完成仅提示我“ nullptr_t”。这太不可思议了。

main.cpp代码:

#include <SFML/Graphics.hpp>

int main()
{
    return 0;
}

点类代码:

#pragma once


class Point
{

private:
    float _x;
    float _y;

public:
    Point();
    Point(float x, float y);
    Point(const Point& p);
    ~Point();

    float getx() { return _x; }
    float gety() { return _y; }

    void setx(float x) { _x = x; }
    void sety(float y) { _y = y; }
};

/ ************************************************** ************************** /

#include "pch.h"
#include "Point.h"


Point::Point()
{
    _x = 0.0;
    _y = 0.0;
}

Point::Point(float x, float y)
{
    _x = x;
    _y = y;
}

Point::Point(const Point& p)
{
    _x = p._x;
    _y = p._y;
}

Point::~Point()
{
}

六角形类:

#pragma once


class Hexagon
{

private:
    Point _center;
    float _diameter;


public:
    Hexagon();
    Hexagon(Point center, float diameter);
    ~Hexagon();
};

/ ************************************************** ************************* /

#include "pch.h"
#include "Hexagon.h"
#include "Point.h"


Hexagon::Hexagon() : _center()
{
    _diameter = 10;
}

Hexagon::Hexagon(Point center, float diameter) : _center(center)
{
    _diameter = diameter;
}

Hexagon::~Hexagon()
{
}

1 个答案:

答案 0 :(得分:0)

您只需要包括iostream库,或在需要的地方将这一行代码添加到包含中。

var dataSourceGrid = new kendo.data.DataSource({
        schema: {
            model: {
                id: "my_line_id",
                fields: modelFields
            },
            data: "data",
            total: "total"
        },
        pageSize: 15,
        serverPaging: false,
        serverFiltering: false,
        serverSorting: false,
        transport: {
            create: {
                url: "./grid.php",
                type: "POST",
                data: {action: 'read', my_id: my_id},
                dataType: "json"
            },
            read: {
                url: "./grid.php",
                type: "POST",
                data: {action: 'read', my_id: my_id},
                dataType: "json"
            },
            update: {
                url: "./grid.php",
                type: "POST",
                data: {action: 'update', my_id: my_id},
                dataType: "json"
            },
            parameterMap: function(data, type) {
                if (type === "read" && data.filter) {
                    $.each(data.filter.filters, function (i, v) {
                        if (v.field === 'field_1') {
                            v.field = 'new_field_1';
                        }
                        if (v.field === 'field_2') {
                            v.field = 'new_field_2';
                        }
                        if (v.field === 'field_3') {
                            v.field = 'new_field_3';
                        }
                        if (v.field === 'field_4') {
                            v.field = 'new_field_4';
                        }
                    });
                }
                if (type === "read" && data.sort) {
                    $.each(data.sort, function (i, v) {
                        if (v.field === 'field_1') {
                            v.field = 'new_field_1';
                        }
                        if (v.field === 'field_2') {
                            v.field = 'new_field_2';
                        }
                        if (v.field === 'field_3') {
                            v.field = 'new_field_3';
                        }
                        if (v.field === 'field_4') {
                            v.field = 'new_field_4';
                        }
                    });
                }
                return data;
            }
        }
    });