64,646
社区成员
发帖
与我相关
我的任务
分享
int a;
int *b = &a;
void myfun(int*& c)
{
a=2;
cout << *c <<endl;
cout << c <<endl;
cout << &a <<endl;
}
int main()
{
myfun(b);
return 0;
}
void main()
{
int str[][4]={{1,2,3,4},{5,6,7,8}};
int* pc1 = (int*)(&str+1);
int* pc2 = (int*)(&str[0]+1);
int* pc3 = (int*)(str+1);
int c1 = *(pc1-1);
int c2 = *(pc2-1);
int c3 = *(pc3-1);
cout << c1 <<endl << c2 << endl << c3 <<endl;
return;
}
class Exception
{
public:
string& getException(){return _str;}
Exception():_str("Normal constructor string"){cout << _str <<endl;}
Exception(const Exception& e):_str("Copy constructor string"){cout << _str <<endl;}
Exception(string str):_str(str){cout << _str <<endl;}
private:
string _str;
};
int main()
{
try
{
Exception e(string("Init exception string"));
throw e;
}
catch (Exception &e)
{
string ecptstr = e.getException();
}
return 0;
}