struct 定义函数体 竟然可以!

来源:互联网 发布:理财软件下载 编辑:程序博客网 时间:2024/06/06 01:08

、、、、、、、、、、、、、、、c语言。。。。。。。。。。。。。。。。。。。。。。。。。

#include<stdio.h>

typedef struct a {
    void test() { //cout<<"asdasdasdas"<<endl;
printf("test\n");
}
} A;


struct test
{
    void fun()
    {
printf("fun");
        //cout<<"hello,world"<<endl;
    }
}_t;


int main(int argc, char* argv[])
{
    a my_a;
    my_a.test();
   struct test _t;
 _t.fun();
  getchar();
    return 0;

}


、、、、、、、、、、、、、、、、、、、、、、、、、c++。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

#include <iostream>

using namespace std;

typedef struct a {
    void test() { cout<<"asdasdasdas"<<endl;}
} A;


struct test
{
    void fun()
    {
        cout<<"hello,world"<<endl;
    }
};


int main(int argc, char* argv[])
{
    A my_a;
    my_a.test();

struct test _t;
_t.fun();

    return 0;
}


原创粉丝点击