小编Met*_*ete的帖子

试图用c ++创建一个三维向量

因此,我试图创建一个3维5x3x2向量,使用向量lib并在每个节点中保存数字4.

多数民众赞成在尝试:

vector<vector<vector<int> > > vec (5,vector <int>(3,vector <int>(2,4)));
Run Code Online (Sandbox Code Playgroud)

对于双维5x8在每个节点中保存int 6,这适用:

vector<vector<int> > vec (5,vector <int>(8,6));
Run Code Online (Sandbox Code Playgroud)

c++

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

得到"未被选中"的Drupal主题

有时,每月至少1次+ - ,当我访问我的网站时,没有选择主题,我得到了很多错误代码.

Notice: Undefined index: highlighted em include() (linha 120 de /var/www/novoportal.faccat.br/htdocs/portal/modules/system/page.tpl.php).
    Notice: Undefined index: sidebar_first em include() (linha 132 de /var/www/novoportal.faccat.br/htdocs/portal/modules/system/page.tpl.php).
    Notice: Undefined index: sidebar_second em include() (linha 138 de /var/www/novoportal.faccat.br/htdocs/portal/modules/system/page.tpl.php).
    Notice: Undefined index: genesis em drupal_theme_initialize() (linha 100 de /var/www/novoportal.faccat.br/htdocs/portal/includes/theme.inc).
    Notice: Trying to get property of non-object em _drupal_theme_initialize() (linha 145 de /var/www/novoportal.faccat.br/htdocs/portal/includes/theme.inc).
    Notice: Trying to get property of non-object em _theme_load_registry() (linha 321 de /var/www/novoportal.faccat.br/htdocs/portal/includes/theme.inc).
    Notice: Undefined index: genesis em theme_get_setting() (linha 1316 de /var/www/novoportal.faccat.br/htdocs/portal/includes/theme.inc).
Run Code Online (Sandbox Code Playgroud)

我总是需要再次选择主题并清除缓存. …

drupal drupal-7 drupal-theming

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

键盘事件SFML 2.0

我试图在SFML 2中使用获得SFML 2中的键输入

   while (App.GetEvent(Event))
       {
          if (App.GetInput().IsKeyDown(sf::Key::Down)) { dir='d'; }
    }
Run Code Online (Sandbox Code Playgroud)

但我不知道如何在SFML 2中做到这一点.

sfml

5
推荐指数
1
解决办法
9450
查看次数

Base unique_ptr 的向量导致 emplace_back(new T()) 上的对象切片

我试图将类型作为参数传递给一个方法,该方法将正确构造对象并将其推送到 unique_ptr 向量,但是创建的对象始终是 Base 对象。使用 emplace_back() 时会发生这种情况,如果我只是实例化对象,同样可以正常工作。

在向量外部构造对象效果很好,但是我不确定如何将指针移动到向量。

body_parts.hpp

#include <vector>
#include <string>
#include <fmt/core.h>

using namespace std;

namespace uhcr {

class body_part
{
  public:
    string name = "Generic";

    template <class T>
    void add_body_part()
    {
      this->body_parts.emplace_back<T*>(new T());
      fmt::print("{}\n", this->body_parts.back()->name);
    }

  private:
    vector<unique_ptr<body_part>> body_parts;

};

class torso : public body_part
{
  public:
    string name = "Torso";
    
};

}
Run Code Online (Sandbox Code Playgroud)

字符.hpp

#include <string>

#include "components/body_parts.hpp"

using namespace std;

namespace uhcr {
  
class character : public body_part
{
  public:
    string name = "Character";
    
}; …
Run Code Online (Sandbox Code Playgroud)

c++ templates stdvector unique-ptr emplace

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