有以下程序:
include<iostream>
using namespace std;
class MyClass
{
public:
static int s;
MyClass();
void SetValue(int val);
};
int MyClass::s=0;
MyClass::MyClass()
{
S++;
}
void MyClass::SetValue(int val)
{
s=val;
}
int main()
{
MyClass my[3],*p;
p=my;
for(int k=0;k<3;k++)
{
p->SetValue(k+1);
p++;
}
cout<<MyClass::s<<end1;
return 0;
}
运行后的输出结果是______。
[单选题]有以下程序 include using namespace std; class MyClass { public:有以下程序 #include<iostream> using namespace std; class MyClass { public: MyClass(intn) {number=n;} //拷贝构造函数 MyClass (MyClass& other) {number=other.number;} ~MyClass(){} private: int number; }
[单选题]有以下程序include using namespace std; class sample { private: int x; public:有以下程序 #include <iostream> using namespace std; class sample { private: int x; public: sample(int a) { x=a; } friend double square(sample s); }; double square(sample s) { return
[单选题]若有以下程序:include using namespace std;class Base {public:Base() { x=0; } int若有以下程序: #include <iostream> using namespace std; class Base { public: Base() { x=0; } int x; }; class Derivedl: virtual public Base { public: Derivedl() { x=10; } }; class Deriv
[单选题]若有以下程序:include using namespace std;class A{private: int a;public: A(int i若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp() { cout<<a<<", "; } }; class B { private: int b; public: B(int
[单选题]若有以下程序:include using namespace std;class Base{public:Base (){x=0;}int x;}若有以下程序: #include <iostream> using namespace std; class Base { public: Base () { x=0; } int x; }; class Derived1 : virtual public Base { public: Derived1 () { x=10; } }; class De
[单选题]若有以下程序:include using namespace std;class A{private:int a;public:A(int i){若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<","; } }; class B { private: int b; public: B(int
[单选题]若有以下程序:include using namespace std;class A{public:A() { }A(int i){x1=i;}v若有以下程序: #include <iostream> using namespace std; class A { public: A() { } A(int i) { x1=i; } void dispa0 { cout<<"x1="<<x1<<","; } private: int x1; }; class B: public A { p
[单选题]若有以下程序:include using namespace std;class A{protected: int a;public: A() {若有以下程序: #include <iostream> using namespace std; class A { protected: int a; public: A() { a=10; } }; class A1 : public A { public: A1() { a=a+1; } }; class A2 : public A { publ
[单选题]若有以下程序:include using namespace std;class data{public: int x; data (int x)若有以下程序: #include <iostream> using namespace std; class data { public: int x; data (int x) { data: :x=x; } }; class A { private: data d1; public: A(int x) : d1 (x) { } void dispa
[单选题]若有以下程序:include using namespace std;class A{private: int x;protected: int若有以下程序: #include <iostream> using namespace std; class A { private: int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx () { return x; }; class B : protect