Thread: A simple question

  1. #1
    Registered User
    Join Date
    Mar 2002

    A simple question


    What does the "*" does when placed after a type?

    For example,

    char* myvar;

    Plus, anyone know of any good c++ reference sites?

  2. #2
    Registered User
    Join Date
    Oct 2001
    it is a pointer. it creates an object that points to another object. it has no real value.

  3. #3
    Registered User
    Join Date
    Mar 2002
    What is the difference between:

    chr* myvar


    chr *myvar ...

  4. #4
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    there's no difference.....

    compiler knows what you're doing in this case so it doesn't matter how u space out your code....

    (pointer) is designed to hold a memeory address.


  5. #5

    no point

    like he said theres really no point to it.. but just to tell you.. when you do

    int *variable;

    that declares a pointer like he said (it points to the memory address) now try this declare another variable and have it point to it.

    int varone;
    int *variable;

    variable = &varone;
    cout << variable;

    take a look at what you get!

  6. #6
    Registered User
    Join Date
    Mar 2002
    like they said, there isn't a difference, but there is one important fact you need to remember about where the * is placed: before the variable name of each pointer being defined.

    char* x, y;
    x will be a pointer, yet y will be just a char
    if you wanted to create 2 pointers it would look like this
    char* x, *y;
    both x and y are now pointers of type char

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM