C++ examples for Class:Member Field
Initializing Class Member Variables, int type and point type
#include <string> using namespace std; class Foo {/* www . ja va 2s. c o m*/ public: Foo() : counter_(0), str_(NULL) {} Foo(int c, string* p) : counter_(c), str_(p) {} private: int counter_; string* str_; }; int main() { string s = "bar"; Foo(2, &s); }