C++读程题: 1. #include<iostream> Using namespace std; Class N{ private: int A;
读程题:1.#include<iostream>Usingnamespacestd;ClassN{private:intA;staticintB;public:N(int...
读程题:
1.
#include<iostream>
Using namespace std;
Class N{
private:
int A;
static int B;
public:
N(int a){A=a;B+=a;}
static void f1(N m)
}
void N::f(N m)}
cout<<"A="<<m.A<<endl;
cout<<"B="<<B<<endl;
}
int N::B=o
int main( ){
N P(5),Q(9);
N::f1(P);
N::f1(Q);
return 0;
}
2.
Class A{
private:int x,y;
public:
A(int i,int y){x=i,y=j;}
virtual int Multic,{return x*y;}
}
Class B:public A{
private:
intw,h;
public:
B(int i,int y,int k,int l)
virtual int Multic( ){return w*h;)
}
B::B(int i,int j,int k,int l):A(i,j)
void f(A&S){cout<<s.Multi( )<<
int main( ){
AobA(1,3) BobB(1.3,34);
f(obA)f(obB)
return 0;
}
3.
temple<typename Elemtype>
Elemtype f(ElemType x)}
return x*(Elem Type)5.1;}
Template<typename ELemType>
void f (ElemType x,ElemType y){
x=x*1.1
y=y*1.1
cout<<x<<endl;cout<<y<<endl;
int main( )}
cout<<f93.0)<<endl;
f(1,2)
f(1.0,2.0)
return 0;
}
4.
Class CArray{
private:
int*m_PArray;
int m_iSize;
public:
(Array (int i Array[ },int iSize);m.pArray(iArray),m_iSize(iSize){ }
int GetSize ( ){return m_iSize;}
int &operator[ ](int iIndex) {return m_pArray[iIndex-1];}
}
int main( )}
int s[ ]={3,7,2,1.5};
cArray oArray(s,5);
oArray [1]=9;
for(int i=1;i<=5;i++}
cout<<oArray[i]<<" ";}
cout<<endl;
return 0;
} 展开
1.
#include<iostream>
Using namespace std;
Class N{
private:
int A;
static int B;
public:
N(int a){A=a;B+=a;}
static void f1(N m)
}
void N::f(N m)}
cout<<"A="<<m.A<<endl;
cout<<"B="<<B<<endl;
}
int N::B=o
int main( ){
N P(5),Q(9);
N::f1(P);
N::f1(Q);
return 0;
}
2.
Class A{
private:int x,y;
public:
A(int i,int y){x=i,y=j;}
virtual int Multic,{return x*y;}
}
Class B:public A{
private:
intw,h;
public:
B(int i,int y,int k,int l)
virtual int Multic( ){return w*h;)
}
B::B(int i,int j,int k,int l):A(i,j)
void f(A&S){cout<<s.Multi( )<<
int main( ){
AobA(1,3) BobB(1.3,34);
f(obA)f(obB)
return 0;
}
3.
temple<typename Elemtype>
Elemtype f(ElemType x)}
return x*(Elem Type)5.1;}
Template<typename ELemType>
void f (ElemType x,ElemType y){
x=x*1.1
y=y*1.1
cout<<x<<endl;cout<<y<<endl;
int main( )}
cout<<f93.0)<<endl;
f(1,2)
f(1.0,2.0)
return 0;
}
4.
Class CArray{
private:
int*m_PArray;
int m_iSize;
public:
(Array (int i Array[ },int iSize);m.pArray(iArray),m_iSize(iSize){ }
int GetSize ( ){return m_iSize;}
int &operator[ ](int iIndex) {return m_pArray[iIndex-1];}
}
int main( )}
int s[ ]={3,7,2,1.5};
cArray oArray(s,5);
oArray [1]=9;
for(int i=1;i<=5;i++}
cout<<oArray[i]<<" ";}
cout<<endl;
return 0;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询