Thread: Couple of questions

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    3

    Couple of questions

    I'm a newbie when it comes to C++ and I have a question.

    Can I assign a struct variable to another struct? If so does it have to have the same name and type?

    THanks

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    what do you mean by that?
    You can do something like this
    Code:
    struct loser
    {
       int Power;
    };
    struct nerd
    {
       int Power;
    };
    int main()
    {
       nerd me;
       loser brian;
       me.Power=10;
       brian.Power=me.Power;
    }
    Two different structs can contain the same variable names that doesn't matter
    Last edited by prog-bman; 07-29-2004 at 09:37 AM.
    Woop?

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    3
    What I mean and sorry for being confusing is can a struct variable be assigned to another in an assignment statement. Do both members of both structs have to have the same name and type?

  4. #4
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    well they have to be the same type(saying this for simpicity don't kick me anyone) but the names don't have to be the same name.
    Woop?

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    3
    Ok, THanks for your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Couple of simple directdraw questions.
    By Deo in forum Game Programming
    Replies: 3
    Last Post: 05-25-2005, 07:55 AM
  2. Studying for Final, Couple Questions...
    By stewade in forum C Programming
    Replies: 4
    Last Post: 05-10-2004, 05:02 PM
  3. A couple of Questions
    By johnnabn in forum C++ Programming
    Replies: 4
    Last Post: 02-24-2003, 10:10 PM
  4. A couple of PowerPoint questions.
    By sean in forum Tech Board
    Replies: 2
    Last Post: 01-27-2003, 05:26 AM
  5. New to C++/ Couple of questions...
    By danielthomas3 in forum C++ Programming
    Replies: 13
    Last Post: 04-14-2002, 03:46 PM