member-variables

    0熱度

    4回答

    我很抱歉,如果標題聽起來很深奧,讓我簡單用一個例子: class A { public: A(int *flag) : flag_(flag) {} void foo(); private: void bar(); int *flag_; }; 的問題是:我可以預防這個類改變flag_指向的值嗎? 注意:我在想,也許我想寫一些像const int

    3熱度

    1回答

    我在MATLAB中有以下目錄結構的項目: +namespace\ @class1\ class1.m @class2\ class2.m mainfile.m 在class1.m我有類似如下的 classdef class1 %readonly variables properties(GetAccess = 'public'

    0熱度

    1回答

    我在想,如果在我以後在其他地方使用(在下面的代碼中,我將傳遞給insertArray()函數)的數組中聲明我的成員變量是不好的約定。在這裏我的代碼: class myClass{ private $ID; private $name; private $type; private $catID; private $isDefault;

    7熱度

    3回答

    我想知道某人會如何命名以字母開頭的成員字段而不是單詞。 public class MyClass { // I know this is how it is for a member field with words. private String myString; // What about this String? It is representing th

    8熱度

    4回答

    你將如何爲具有接口成員變量的類編寫複製構造函數? 例如: public class House{ // IAnimal is an interface IAnimal pet; public House(IAnimal pet){ this.pet = pet; } // my (non-working) attempt at a

    2熱度

    4回答

    我有一個abstract class具有可變像如下: public abstract class MyAbstractClass { int myVariable = 1; protected abstract void FunctionThatUsesMyVariable(); } 然後,當我通過下面的代碼實例化了我class,myVariable不能看出: MyA

    2熱度

    6回答

    我對Java中的局部變量和成員變量有疑問。情況是:有時如果我定義一個局部變量,那麼該變量必須被傳遞到幾個方法調用級別。我經常想,爲什麼要爲類定義一個成員變量,以便該類中的變量可用。類的成員變量就像一個全局變量,可以在類中隨處訪問。 這種情況下的最佳做法是什麼?或者什麼是正確的做法? 如果我將它定義爲一個成員變量,它應該是一個靜態或非靜態變量?

    0熱度

    1回答

    在我的C++/QT應用我有一個結構與數以百計的變量,如下面的組織: struct MyStruct { int a1; double a2; struct InnerStruct { int b1; bool b2; struct InnerInnerStruct { char c1;

    4熱度

    5回答

    我對C#有點新,但是在編程方面我有相當廣泛的背景。 我在做什麼:爲遊戲定義不同的MapTiles。我定義的基本MapTile類是這樣的: public class MapTile { public Texture2D texture; public Rectangle mapRectangle; public MapTile(Rectangle rectangle

    0熱度

    1回答

    我有一個Form具有類似下面的代碼: public partial class Form1 : Form { private int m_var1; private int m_var2; string sMsg; bool bReturn; private bool MyFunction() { // POINT A: