基本知识: http://www.cs.virginia.edu/~evans/cs216/guides/x86.html
#include <iostream>
using namespace std;
/*Function to return struct */
struct A
{
int ma;
int mb;
int mc;
int md;
int me;
};
struct A fun(void)
{
struct A a1;
a1.ma = 1;
a1.mb = 2;
a1.mc = 3;
a1.md = 4;
a1.me = 5;
return a1;
}
class B
{
public:
B() { cout << "hello"<<endl;}
B(B& b) { i = b.i;cout << "hello"<<endl;}k
~B() {cout << "bye" <<endl;}
int i;
};
/*Function to return class */
B fun2(void)
{
B b;
b.i = 1;
return b;
}
int main(int argc,char *agrv[])
{
//test the struct return
struct A a2;
a2 = fun();
//test class return and initialize the class variable
B b2= fun2();
//test class return and assign the class variable
B b3;
b3 = fun2();
return 0;
}