Thread: Functions in class and class variables.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    7

    Functions in class and class variables.

    The class doesn't sees the function "place();" in the main.cpp and the int x and int y is also not recognized when using it in the functions owned by the class:

    Code:
    #ifndef ORGAN_H
    #define ORGAN_H
    
    class Organ
    {
    public:
        int x;
        int y;
     
        void kill(int a,int b);
        void it_lives(int prop);
        void SetCoord(int x, int y);
    
    };
    
    #endif // ORGAN_H
    Code:
    #include "organ.h"
    
    void SetCoord(int x, int y)
    {
        place(x,y,"@");//ERROR: Undeclared
    }
    void kill(int a,int b)
    {
        x=a;//ERROR: x and y undefined
        y=b;
        place(x,y," ");
    }
    void it_lives(int prop)
    {
        if(prop==0)
        {
            kill(x,y);
        }
    }
    place(); is defined in the main.cpp file. The header file is defined in the main.cpp.
    Last edited by Karakus; 01-15-2006 at 02:32 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  3. Replies: 3
    Last Post: 10-31-2005, 12:05 PM
  4. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  5. Class and functions
    By Rune Hunter in forum C++ Programming
    Replies: 15
    Last Post: 08-05-2005, 09:17 PM