Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

static member fn , instance

struct ST {
    ST(const std::string& ss = "Wolf", int ii = 359) : s(ss), i(ii) { }

    int get_i() const { return i; }
    bool compare_i(const ST& other) const { return (i == other.i); }

  private:
    std::string s;
    int i;
};
ST st1;
ST st2("Species", 8472);

int  i = st1.get_i(); // Can access st1.i, but not st2.i.
bool b = st1.compare_i(st2); // Can access st1 & st2.
Source by sodocumentation.net #
 
PREVIOUS NEXT
Tagged: #static #member #fn #instance
ADD COMMENT
Topic
Name
9+8 =