我刚刚创建了一个带有整数变量和指针变量的类.创建对象后,我将其传递给函数.即使在返回函数之后,程序也没有抛出异常
#include"iostream"
using namespace std;
class A
{
public :
int i;
char *c;
void show();
};
void func(A obj);
int main()
{
A a;
a.i = 10;
a.c = "string";
cout << " Before Fun " << endl;
a.show();
cout << " Going To Call func " << endl;
func(a);
cout << " After func " << endl;
a.show();
return 0;
}
void A::show()
{
cout << " The valuses in Object are " << i << '\t' << …Run Code Online (Sandbox Code Playgroud) c++ ×1