相关疑难解决方法(0)

在C++标识符中使用下划线有哪些规则?

在C++中通常用某种前缀命名成员变量来表示它们是成员变量而不是局部变量或参数.如果你来自MFC背景,你可能会使用m_foo.我myFoo偶尔也见过.

C#(或者可能只是.NET)似乎建议只使用下划线,如_foo.这是否允许C++标准?

c++ standards naming-conventions c++-faq

906
推荐指数
4
解决办法
24万
查看次数

在c ++类中访问getter setter中的struct变量

好的,我在C++中有这样的东西:

class MyClass{
private:
  int someVariable;
  int someOtherVariable;

  struct structName{
    int someStructVariable;
    int someOtherStructVariable;
  };//end of struct

public:
  //getters & setters for the defined variables.

  int getSomeStructVariable()
  {
    // this does not work I get this error: "error: expected primary-expression
    // before '.' token"
    return structName.someStructVariable;
  } 
};//end of class
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我该如何写我的getter或setter?

c++ getter setter struct

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

标签 统计

c++ ×2

c++-faq ×1

getter ×1

naming-conventions ×1

setter ×1

standards ×1

struct ×1