E
Ed
Hi, guys,
In C language manner, we need to put a "struct" token before one
struct variable declaration like following.
<code>
struct Apple
{
float Price;
};
struct Apple apple;
</code>
Sometime, we would use typedef to simplify the usage.
<code>
typedef struct _Apple
{
float Price;
} Apple;
Apple apple;
</code>
Now, when we use this manner in C++, it seems we don't need to add a
typedef for the struct declaration.
<code>
struct Apple
{
float Price;
};
Apple apple;
</code>
Directly using "Apple" to do the declaration is OK in VS compiler and
Intel Compiler.
My question is should I still keep the usage of old struct usage.
Why I ask this question is because of template.
I write a template struct.
template <typename Real>
struct Vector
{
Real x;
Real y;
Real z;
};
Vector<float> vector;
You know that we can not add a typedef to a template struct. So, I am
wondering if this is OK.
Thanks!
Ed.
In C language manner, we need to put a "struct" token before one
struct variable declaration like following.
<code>
struct Apple
{
float Price;
};
struct Apple apple;
</code>
Sometime, we would use typedef to simplify the usage.
<code>
typedef struct _Apple
{
float Price;
} Apple;
Apple apple;
</code>
Now, when we use this manner in C++, it seems we don't need to add a
typedef for the struct declaration.
<code>
struct Apple
{
float Price;
};
Apple apple;
</code>
Directly using "Apple" to do the declaration is OK in VS compiler and
Intel Compiler.
My question is should I still keep the usage of old struct usage.
Why I ask this question is because of template.
I write a template struct.
template <typename Real>
struct Vector
{
Real x;
Real y;
Real z;
};
Vector<float> vector;
You know that we can not add a typedef to a template struct. So, I am
wondering if this is OK.
Thanks!
Ed.