The typedef functionality is just a quick C hack, i.e. any tentative declaration
with the word 'typedef' in front of it turns the 'variable' into an alias for the type
of the variable.
If T wasn't a struct tag name before it'll cause an error in your text. What is/was T?
kind regards,
Jos
Hi,
I am using it to provide a type of data hiding method,
This is my .h file :-
================================
typedef struct TMan *Man_ptr;
Man_ptr Man_Create(int w, char c, short h);
================================
This is my .c file :-
================================
#include <stdlib.h>
#include "TMan.h"
struct TMan
{
int Weight;
char Colour;
short Hieght;
};
Man_ptr Man_Create(int w, char c, short h)
{
Man_ptr result = (Man_ptr)malloc(sizeof(struct TMan));
if(result)
{
result->Weight = w;
result->Colour = c;
result->Hieght = h;
}
return result;
}
================================
Then in the Main .c file :-
================================
#include "TMan.h"
void main()
{
int i;
Man_ptr MyMan;
MyMan = Man_Create(1, 2, 3);
}
================================
There is obviously more but to simplfy it ive just shown 1 method, its trying to create an object then manipulate it with object methods, like you would in C++ classes, to hide the struct data from main, you know OOP. I just dont understand why this will not compile with my C compiler but will with C++ when this is the way to do C++ data hiding in C, or so i thought.
Any Idea's.