Like Tree1Likes
  • 1 Post By oogabooga

Why Won't My Program Read My .hpp file?

This is a discussion on Why Won't My Program Read My .hpp file? within the C++ Programming forums, part of the General Programming Boards category; Hey guys just wondering wether one of you guys could help me with my program and why it's not reading ...

  1. #1
    Registered User Insidia's Avatar
    Join Date
    Jan 2012
    Posts
    1

    Why Won't My Program Read My .hpp file?

    Hey guys just wondering wether one of you guys could help me with my program and why it's not reading my .hpp file.

    RECT.cpp
    Code:
    #include "Rect.hpp"
    Rectangle::Rectangle(int top, int left, int bottom, int right)
    {
          itsTop = top;
          itsLeft = left;
          itsBottom = bottom;
          itsRight = right;
          
          itsUpperLeft.SetX(left);
          itsUpperLeft.SetY(top);
          
          itsLowerLeft.SetX(right);
          itsLowerLeft.SetY(top);
          
          itsUpperRight.SetX(left);
          itsUpperRight.SetY(bottom);
          
          itsLowerRight.SetX(left);
          itsLowerRight.SetY(bottom);
    }
          int Rectangle::GetArea() const
          {
              int Width = itsRigth - itsLeft;
              int Height = itsTop - itsBottom;
              return (width * Height);
              }
              
              int main()
              {
                  Rectangle MyRectangle.GetArea();
                  
                  cout << "Area: " << Area << "\n";
                  cout "Upper Left X Coordinate: ";
                  cout << MyRectangle.GetUpperLeft().GetX();
                  return 0;
    Rect.hpp
    Code:
    #include <iostream>
    class Point        // hold x, y coordinates
    {
          // no constructor, use default
          public:
                 void SetX(int x) { itsX = x; }
                 void SetY(int y) { itsY = y; }
                 int GetX()const { return itsX;}
                 int GetY()const { return itsY;}
          private:
                  int itsX;
                  int itsY;
                  };       // end of Point Class declaration
                  
                  Class Rectangle
                  {
                        public:
                               Rectangle (int top, int left, int bottom, int right);
                               ~Rectangle () {}
                               
                               int GetTop() const { return itsTop; }
                               int GetLeft() const { return itsLeft; }
                               int GetBottom() const { return itsBottom; }
                               int GetRight() const { return itsRight; }
                               
                               Point GetUpperLeft() const { return itsUpperLeft; }
                               Point GetLowerLeft() const { return itsLowerLeft; }
                               Point GetUpperRight() const { return itsUpperRight; }
                               Point GetLowerRight() const { return itsLowerRight; }
                               
                               void SetUpperLeft(Point Location) {itsUpperLeft = Location;}
                               void SetLowerLeft(Point Location) {itsLowerLeft = Location;}
                               void SetUpperRight(Point Location) {itsUpperRight = Location;}
                               void SetLowerRight(Point Location) {itsLowerRightt = Location;}
                               
                               void SetTop(int top) { itsTop = top; }
                               void SetLeft(int left) { itsLeft = left; }
                               void SetBottom(int bottom) { itsBottom = nottom; }
                               void SetRight(int right) { itsRight = right; }
                               
                               int GetArea() const;
                               
                        private:
                                Point itsUpperLeft;
                                Point itsUpperRight;
                                Point itsLowerLeft;
                                Point itsLowerRight;
                                int itsTop;
                                int itsLeft;
                                int itsBottom;
                                int itsRight;
                                };
    If you can help me thanks a lot, and i'm using Dev-C++.

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    It's just some spelling mistakes. Doesn't your compiler warn you? class cannot be spelled with a capital C, for instance. Look also for "nottom" and "itsLowerRightt" (note the double t).
    Salem likes this.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,179
    Indentation is pretty bad... good idea to fix that.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic file read, file write program
    By starwarsyeah in forum C++ Programming
    Replies: 5
    Last Post: 02-28-2011, 02:23 PM
  2. C program file read/write help
    By BobDole11 in forum C Programming
    Replies: 5
    Last Post: 10-13-2008, 09:55 AM
  3. Simple File Read Program...
    By PowerHouse in forum C Programming
    Replies: 9
    Last Post: 10-07-2008, 11:30 PM
  4. Can I write & read file in same program?
    By chad03 in forum C Programming
    Replies: 2
    Last Post: 08-04-2003, 08:39 AM
  5. Read a file into a loop program
    By TimeClock in forum C Programming
    Replies: 5
    Last Post: 07-17-2003, 06:29 PM

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