Re: Problem forward declaration of "typedef struct"
On 19 Feb, 14:10, "Mohammad Omer Nasir" <momer...@gmail.com> wrote:
can forward declare it with just struct A;.
But i defined AA specifically for making Objects
Don't need a typedef for that.
and LPAA for specifically pointer of A structure...
Why? What's wrong with A*? Anyway, you can still do:
typedef A* LPAA;
ok lets look at this, this code taken from winnt.h header file
typedef struct _RTL_CRITICAL_SECTION {
PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
LONG LockCount;
LONG RecursionCount;
HANDLE OwningThread;
HANDLE LockSemaphore;
ULONG_PTR SpinCount;
} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
y is this developer declaring _RTL_CRITICAL_SECTION and
RTL_CRITICAL_SECTION and *PRTL_CRITICAL_SECTION, when he could also
have done what u told me?
Yes. Because the typedef syntax is (or used to be) necessary in C. I
can't remember exactly why, but it has never been necessary in C++.
Becuz it lets us declare a lot of types in one declaration.
Not really. The only extra thing you get is PRTL_CRITICAL_SECTION
which you can use to obfuscate the present of a pointer.
The same thing is what I'm trying to achieve and I'm
getting an error and I want to understand y i'm getting an error. I
can figure out the workarounds (and I have, u also gave a solution)
but first I >want< to understand whats happening in the current
situation.
Your original post contained this
typedef struct A
{
int i;
A( )
{
i = 90;
}
} AA, * LPAA;
Now, to remove some unnecessary confusion, replace the above with
struct A
{
int i;
A( )
{
i = 90;
}
};
Replace *all* occurances of AA with A and replace *all* occurances of
LPAA with A*. Other than making your code easier to read, this should
have *no effect* on your problem. But it will make reading the code to
work out what's wrong easier.
Gavin Deane