typedef问题 [英] typedef problems

查看:102
本文介绍了typedef问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谢谢您的帮助!

在我的头文件中,我有:

Thank you for all your help!

In my header file I have :

typedef struct
{
    char name[10];
    char address[10];
    struct node *next;
} Link;




在主要代码中,我有:




in the main code I have:

// linkedlist.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <Source1.h>

int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}



几个问题:

如何使用主文件头文件中的结构?
如何在主文件中使用其成员?
如何使其全球化?

John



A couple of questions:

How do I use the structure in the header file in main file?
How do I use its members in the main file?
How do I make it global?

John

推荐答案

假定"Link"位于文件"source1.h"中,然后声明它的一个实例:
Assuming "Link" is in the file "source1.h", then just declare an instance of it:
#include "stdafx.h"
#include <Source1.h>

Link myLink;

int _tmain(int argc, _TCHAR* argv[])
{
    myLink.name[0] = ''A'';
    return 0;
}

这为您提供了一个全局实例"myLink",您可以使用它的成员.

That gives you a global instance "myLink" and you can use it''s members.


这篇关于typedef问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆