passing a struct!

This is a discussion on passing a struct! within the C++ Programming forums, part of the General Programming Boards category; Heya all, i'm trying to pass a structure through a copy constructor, but the class can not seem to see ...

  1. #1
    Registered User OxYgEn-22's Avatar
    Join Date
    Apr 2002
    Posts
    36

    Talking passing a struct!

    Heya all, i'm trying to pass a structure through a copy constructor, but the class can not seem to see the structure. any ideas on why?, the structure is global before the class file is called(i know, i know.. bad me for having a global struct)

    s_iChrStat <-- character stats

    Code:
    class CBasePlayer
    {
    	CBasePlayer();
    	CBasePLayer(s_iChrStat stats);
    
    private:
    	s_iChrStat s_charstat;
    };
    the class, i cut out alot of usless garbage, this is basically where my problem is.

    Code:
    CBasePlayer::CBasePLayer()
    {
    
    }
    
    CBasePlayer::CBasePLayer(s_iChrStat stats):
    s_charstat(stats)
    {
    	cout << "Base Player copy constuctor..\n";
    }
    then this is the .cpp file.
    Is that air you're breathing?

  2. #2
    Unregistered
    Guest
    anyone?

  3. #3
    Registered User OxYgEn-22's Avatar
    Join Date
    Apr 2002
    Posts
    36

    Unhappy

    I guess this is an advanced question.
    Is that air you're breathing?

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    Can't it find the global struct decleration or the struct definition? if you can't find the global declared struct look up extrern keyword and use it. If it can't find the struct definition, look over your headerfile includings.

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    can't say as I've ever tried to use a struct with the initializing operator. I would try member by member initialzing within the body of the constructor. If that doesn't work then more code (particualarly code for the struct) will be helpful for further evaluation.

  6. #6
    Registered User OxYgEn-22's Avatar
    Join Date
    Apr 2002
    Posts
    36
    thanks guys, i found my problem. It seems i needed to include the file that contained the struct again in the class header file. thanks all!
    Is that air you're breathing?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Concatenating in linked list
    By drater in forum C Programming
    Replies: 12
    Last Post: 05-03-2008, 12:10 AM
  2. passing struct
    By Doxygen in forum C Programming
    Replies: 2
    Last Post: 10-26-2006, 04:05 AM
  3. Search Engine - Binary Search Tree
    By Gecko2099 in forum C Programming
    Replies: 9
    Last Post: 04-17-2005, 03:56 PM
  4. Passing a struct
    By Drainy in forum C Programming
    Replies: 3
    Last Post: 03-14-2005, 11:02 AM
  5. passing struct to function help
    By staticalloc in forum C Programming
    Replies: 4
    Last Post: 10-06-2004, 09:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21