Help Please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hjast
    New Member
    • Oct 2007
    • 9

    Help Please

    I am doing an assingment for class and I have everything execpt it will not compile. I get these errors

    /Users/hjast89/Desktop/test/shape.cpp:36: error: expected `}' at end of input
    /Users/hjast89/Desktop/test/shape.h:25: error: virtual outside class declaration
    /Users/hjast89/Desktop/test/shape.h:25: error: function 'void draw()' is initialized like a variable
    /Users/hjast89/Desktop/test/shape.cpp:15: error: a function-definition is not allowed here before '{' token
    /Users/hjast89/Desktop/test/shape.cpp:22: error: a function-definition is not allowed here before '{' token
    /Users/hjast89/Desktop/test/shape.cpp:29: error: a function-definition is not allowed here before '{' token
    /Users/hjast89/Desktop/test/shape.cpp:34: error: a function-definition is not allowed here before '{' token
    /Users/hjast89/Desktop/test/shape.cpp:36: error: expected `}' at end of input
    /Users/hjast89/Desktop/test/shape.cpp: At global scope:
    /Users/hjast89/Desktop/test/shape.cpp:36: error: expected unqualified-id at end of input
    Build failed (9 errors, 1 warning)

    Code:
    #include "shape.h"
    #include <iostream>
    
    
    int Shape::getCenter_X()
    {
      cout << "In the Shape: get Center X" << endl;
      // Code for the withdraw function here
      return 1;
    }
    
    int Shape::getCenter_Y()
    {
      cout << "In the Shape get Center Y" << endl;
      // Code for showAllChecksCleared() function here
      return 1;
    }
    
    void Circle::printAllValues ()
    {
      cout << "In the Circle print all values" << endl;
    }
    
    void Rectangle::printAllValues()
    {
    	cout <<"In the Rectangle print all values" <<endl;
    }
    This is the code that it gives it to me. The .h file just has the class definitions. I would appreciate if someone could tell me what I am doing wrong.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    The .h may just contain the class definition but that is where I suspect the error is.

    Comment

    • hjast
      New Member
      • Oct 2007
      • 9

      #3
      Here is the the code for the .h


      Code:
      #include <iostream.h>
      
      
      class Shape
      {
        private:
           int x_Center, y_Center;
       
        public:
      	Shape()
      	{
      	cout <<"In defualt constructer";
      	}
           // Constructors
           Shape(int cx, int cy)
      	{
      		x_Center=cx;
      		y_Center=cy;
      	{
      
           // Member functions
           void getCenter_X();
           void getCenter_Y();
           virtual void draw()=0;
      };
      
      class Rectangle : public Shape
      {
      private:
      	int length,width;
      
       public:
      
        // Default constructor
        Rectangle ()
          {
            cout << "In the default constructor of CheckingAccount" << endl;
          }
      
        // Constructor
        Rectangle (int cx, int cy,int l,int w) : Shape(cx, cy)
          {
      	length=l;
      	width=w;
            cout << "In CheckingAccount constructor" << endl;
          }
      
          // Destructor
          ~Rectangle ()
            {
      	cout << "In CheckingAccount destructor" << endl;
            }
      
          // Methodds
          void printAllValues();
      };
      
      class Circle : public Shape
      {
      private:
      int diameter;
      
       public:
      
        // Default Constructor
        Circle ()
          {
            cout << "In the default constructor of IRA_Account" << endl;
          }
      
        // Constructor
        Circle (int ssn, int acctNum) : Shape (ssn, acctNum)
          {
            cout << "In IRA_Account constructor" << endl;
          }
      
          // Destructor
          ~Circle ()
            {
      	cout << "In IRA_Account destructor" << endl;
            }
      
          // Methods
          void printAllValues();
      };

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Line 19 you have { where you need }

        Comment

        Working...