So the problem seems to be when i try to compile its telling me on line 16 of the main program (the last line) "unqualified-id at end of input" and "expected ',' or ';" at end of input

I played with just about every combination of ending brackets and semi colons i could think of but i just can't get it to compile. I'm at a loss as to what's wrong ... I use "context, and cygwin" to write the program and compile it.

oh and while your here i might as well ask you, do you know how to automatically call the class's functions from main?

Thanks for any help!!

here's my program::::

#include <iostream>

using std::cout;
using std::cin;
using std::endl;
#include "plot.h"

int main()
{
  plot plot1;

  cout << "Available functions are:" <<endl;
  cout << "Area" <<endl;
  cout << "Perimeter" << endl;
  cout << "Please type selection" <<endl;
  return 0;
}

here's my class saved as plot.h

class plot
{
       int x1, y1, x2, y2;

public:
       void EnterDimensions()
       {
       cout <<"enter x-value of lower left point"<<endl;
       cin >> x1;
       cout <<"enter y-value of lower left point"<<endl;
       cin >> y1;
       cout <<"enter x-value of upper right point"<<endl;
       cin >> x2;
       cout <<"enter y-value of upper right point"<<endl;
       cin >> y2;
       }
  int Height() { return (y2-y1); }
  int Width() { return (x2-x1); }
       

       int Area()
       {
        return Width()*Height();
       }


       int Perimeter()
       {
       return 2*Width()+2*Height();
       };

You're missing one closing bracket in your header file (plot.h). Change it to :

[....rest of code]
    return 2*Width()+2*Height();
    } //<----- ADD THIS ONE
};

And it should compile.

These kind of errors can easily be avoided if you indent your code. I personally like the K&R style, but that's a matter of opinion.

Also next time you post code, use code tags.

oh and while your here i might as well ask you, do you know how to automatically call the class's functions from main?

Yes I do.

//in main.c
int main()
{
    plot plot1;
    plot.EnterDimensions(); // <--call to function
[...etc...]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.