小编sho*_*mit的帖子

如何调用适当的构造函数

为什么我不能为该Geometry对象调用适当的构造函数?

class Geometry {
private:
  float fRadius;
  int iSegments;
  float fWidth;
  float fLenght;
  std::string stdstrType;
  bool bValid;

public:
  Geometry() {
    // Set data Elements
    qDebug() << "Constructor 1 is called";
  }

  Geometry(float Radius, int Segments, float Width, float Length,
    std::string strType, bool bValue) {
    // Set data Elements
    qDebug() << "Constructor 2 is called";
  }

  Geometry(const Geometry & g) {
    // Set data Elements
    qDebug() << "Constructor 3 is called";
  }
}
Run Code Online (Sandbox Code Playgroud)

我将此类用作另一个类中的数据变量。

class Container {
private:
  std::string …
Run Code Online (Sandbox Code Playgroud)

c++ visual-c++ c++11

8
推荐指数
1
解决办法
306
查看次数

GLFW window creation options affecting the HarfBuzz

I am using HarfBuzz along with freetype to render regional language hindi.

If I write these three optins for window creation than the font does not render and I only see the blank screen.

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
Run Code Online (Sandbox Code Playgroud)

Without these three options the font renders correctly.

I am curious to know what difference these options make in window creation?

opengl glsl freetype glfw harfbuzz

4
推荐指数
1
解决办法
57
查看次数

如何删除基于空格的字符串

我有一个std :: string我想在Newa和Newb这样的两个空格之后保留字符串

std::string a = "Command send SET Command comes here";
std::string b = "Command GET Command comes here"; 

std::string Newa = "SET Command comes here";
std::string Newb = "Command comes here";
Run Code Online (Sandbox Code Playgroud)

我想到的是,我可以做std::string::find(' ')两次并用它std::string::substr来获得期望的结果。

我们能否以更精致的方式做到这一点。

c++ c++11

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

如何重载模板功能

我试图在类中重载模板函数,但没有成功。

如何在代码中超载模板。

class CommandInterfaceFont
{
private:
    std::map < std::string, FontParam > lookUpMap;

public:
    CommandInterfaceFont();
    friend class SumCommandInterface;

    template <typename plug , typename typeValue >
    void SetValue(plug* geom, std::string stdstrParamName, typeValue value);

};
Run Code Online (Sandbox Code Playgroud)

///////////////////////////////////////////////////// ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// //////

template <typename plug >
void CommandInterfaceFont::SetValue(plug* geom, std::string stdstrParamName, std::string value)
{       
            geom->setText(value);       
}

template <typename plug >
void CommandInterfaceFont::SetValue(plug* geom, std::string stdstrParamName, bool value)
{   
            geom->setUseShadow(value);      
}
Run Code Online (Sandbox Code Playgroud)

c++ c++11 c++14

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

标签 统计

c++ ×3

c++11 ×3

c++14 ×1

freetype ×1

glfw ×1

glsl ×1

harfbuzz ×1

opengl ×1

visual-c++ ×1