Is anyone here familiar with using typedef like this:
What exactly does that do?Code:typedef string type[];
Is anyone here familiar with using typedef like this:
What exactly does that do?Code:typedef string type[];
A typedef declaration does not introduce a new type,only a synonym for the type specified.
In your example
Code:typedef string type[]; ... type strArray = { "Hello","World"};
yeah, like Wledge said. it makes 'type' represent a string array. now you dont need all that harsh typing of "string[]" you can just use "type".Originally posted by volk
What exactly does that do?
Why wouldn't that typedef be written like this instead:
typedef string[] type;
im not sure if this is true for c++ (ive been programming alot of Java at work lately) but i dont think it matters where the brackets go.Originally posted by 7stud
Why wouldn't that typedef be written like this instead:
typedef string[] type;
string [] var; == string var[];
I'm pretty sure that only:
type name[];
is valid in C++.
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
I thought with a typedef what's on the right is a synonym for what's on the left. So, it seems to me if you declared your typedef like this:
typedef string type[]
then type[] would be the synonym for string, and you would have to declare a string like this:
type[] text;
What's the deal with typedef?
this is the way it's used:
this is C++ - i'm not sure about java...Code:... typedef char string20[20]; string20 name; cin.getline(name,20,'\n'); ...
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
Not necessarily, exactly. Its syntax is supposed to resemble that of a variable declaration. Think of these:Originally posted by 7stud
I thought with a typedef what's on the right is a synonym for what's on the left. So, it seems to me if you declared your typedef like this:
typedef string type[]
then type[] would be the synonym for string, and you would have to declare a string like this:
type[] text;
What's the deal with typedef?
foo's type is a char[], just like "bar" is a synonym for char[]. So the example works because it's analogous to the way you declare an array of something.Code:char foo[5]; typedef char bar[] // the example in question
I think it *does* matter where the brackets go:
But I have not yet been able to check these.Code:char* foo; // Either the * in front char bar[5]; // or brackets after typedef char* foo; // ditto typedef char foo[];