When to use thing->member as opposed to thing.member?

When to use thing->member as opposed to thing.member?

Post by Rubber Duc » Thu, 28 Nov 2002 00:51:26



When to use thing->member as opposed to thing.member?

All,

when should I set a member variable using
thing->member = "hello";
as opposed to
thing.member = "hello";

RD

 
 
 

When to use thing->member as opposed to thing.member?

Post by Gernot Frisc » Thu, 28 Nov 2002 01:19:08


??
thing->member // thing is a pointer to object of type xx
thing.member  // thing is an object of type xx

??
Was that the question??
-Gernot



| When to use thing->member as opposed to thing.member?
|
| All,
|
| when should I set a member variable using
| thing->member = "hello";
| as opposed to
| thing.member = "hello";
|
| RD
|
|

 
 
 

When to use thing->member as opposed to thing.member?

Post by Scott McPhillip » Thu, 28 Nov 2002 12:21:17



> When to use thing->member as opposed to thing.member?

> All,

> when should I set a member variable using
> thing->member = "hello";
> as opposed to
> thing.member = "hello";

> RD

The good news is: the compiler knows the answer and it will not compile
if you do it wrong.

From your other question, it seems you have not learned about 'new' and
pointers yet.  That is something very important to learn.  The -> symbol
is used with pointers.

--
Scott McPhillips [VC++ MVP]

 
 
 

When to use thing->member as opposed to thing.member?

Post by Charlie Gibb » Thu, 28 Nov 2002 09:50:20




>When to use thing->member as opposed to thing.member?

>All,

>when should I set a member variable using
>thing->member = "hello";

In this case, "thing" is a pointer to a structure.

Quote:>as opposed to
>thing.member = "hello";

In this case, "thing" is the structure itself.

Here's a little program that will illustrate the difference.
(I actually compiled and ran it so I know it works.)

#include <stdio.h>

struct foo {
    char *member;
    int anothermember;

Quote:};

int main (int argc, char **argv)
{
    struct foo thing;           /* A structure */
    struct foo *pthing;         /* A pointer to a structure */

    thing.member = "hello";     /* Set the structure member. */
    pthing = &thing;            /* Set a pointer to the structure. */

    printf ("%s\n", thing.member);      /* This will print "hello". */
    printf ("%s\n", pthing->member);    /* So will this. */

Quote:}

Hope this helps.

BTW you'll probably get better results (and possibly fewer flames) if
you post questions like this to comp.lang.c, since this is a general
C programming question, not a Windows-specific one.

--

\ /  I'm really at moc.subyks if you read it the right way.
 X   Top-posted messages will probably be ignored.  See RFC1855.
/ \  HTML will DEFINITELY be ignored.  Join the ASCII ribbon campaign!

 
 
 

When to use thing->member as opposed to thing.member?

Post by Rubber Duc » Thu, 28 Nov 2002 17:54:47


Quote:> The good news is: the compiler knows the answer and it will not compile
> if you do it wrong.

> From your other question, it seems you have not learned about 'new' and
> pointers yet.  That is something very important to learn.  The -> symbol
> is used with pointers.

So when is the 'new' keyword used???
 
 
 

When to use thing->member as opposed to thing.member?

Post by Dave » Thu, 28 Nov 2002 22:55:14



Quote:> > The good news is: the compiler knows the answer and it will not compile
> > if you do it wrong.

> > From your other question, it seems you have not learned about 'new' and
> > pointers yet.  That is something very important to learn.  The -> symbol
> > is used with pointers.

> So when is the 'new' keyword used???

When dynamically creating something.
This is pretty basic.  Have you studied C or C++ programming yet?  If not,
it would help you if you did.

dave h

 
 
 

1. Blank Member Of names for User and Group members

I have a Windows XP workgroup PC that shows blank names for members of
groups.  It also shows blank names for group names for each user account.

If you open the Administrators group and click on the Member Of tab it
shows 1 icon with a blank name.

If you open the Administrator user and click on the Member Of tab it
shows 2 icons with blank names beside each.

If you open the Administrators group and click Add ... then click
Advanced ... FindNow returns no user accounts (object type is "Users or
Built-in security principals").

Anyone know why or what is going on?

2. HELP: VFAT initialisation error on startup

3. member function and member variable

4. Cannot run any .exe file

5. Changing a member server into a PDC and a PDC into a member server...

6. How can I register adofiltr.dll on my Pocket PC.

7. From domain member 2 workgroup member

8. WMP7 Skips

9. Tool for getting rid of the ">>>" things in email/postings

10. Thing 1 and Thing 2 (and what to do?)

11. W2K Member Server and NT4 DC separated by firewall --> Ports

12. Using Inline Assembler With C++ Members

13. CodeWarrior compiler crashes when using wxWindows and STL member function adapters