вот уже сегодня первый раз написал простенькую программу,мне понравилось,сразу после этого в книге пригигантская программа,которая считывает координаты точек,и в конце выводи площадь прямоуголника...вот коды
main
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| #include "windows.h"
#include "rect.h"
rectangle::rectangle(int top,int left,int bpttom,int right)
{
itstop=top;
itsbottom=bottom;
itsleft=left;
itsright=right;
itsUpperLeft.SetX(left);
itsUpperLeft.SetY(top);
itsUpperRight.SetX(right);
itsUpperRight.SetY(top);
itsLowerLeft.SetX(left);
itsLowerLeft.SetY(bottom);
itsLowerRight.SetX(right);
itsLowerRight.SetY(bottom);
}
int rectangle::GetArea() const
{
int width=itsright-itsleft;
int height=itstop-itsbottom;
return (width*height);
}
int main(){
rectangle=MyRectangle(100,20,50,80);
int area=MyRectangle.GetArea();
cout<<"Upper left x coordinate:"<<MyRectangle.GetUpperLeft().GetX();
return 0;
} |
|
rect.h
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| #include "windows.h"
#include<iostream>
class point{
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 itsy;
int itsx;
};
class rectangle
{
public:
rectangle(int top,int left,int bottom,int right);
~rectangle(){}
int GetTop() const {return itstop;}
int GetLeft() const {return itsleft;}
int GetRight() const {return itsright;}
int GetBottom() const {return itsbottom;}
point GetUpLeft() const{return itsUpperLeft;}
point GetLowerLeft()const{return itsLowerLeft;}
point GetUpRight() const{return itsUpperRight;}
point GetLowerRight()const{return itsLowerRight;}
void setUpperLeft(point location){itsUpperLeft=loaction;}
void setLowerLeft(point location){itsLowerLeft=loaction;}
void setUpperRight(point location){itsUpperRight=loaction;}
void setLowerRight(point location){itsLowerRight=loaction;}
void SetTop(int top){itstop=top;}
void SetLeft(int left){itsleft=left;}
void SetRight(int right){itsright=right;}
void SetBotton(int bottom){itsbottom=bottom;}
int GetArea()const;
private:
point itsUpperLeft;
point itsLowerLeft;
point itsUpperRight;
point itsLowerRight;
int itstop;
int itsleft;
int itsright;
int itsbottom;
}; |
|
сразу нашел около 20 ошибок...не могу уже 4часа работаю сил не хватает
вот эти геморные ошибки,у меня уже не мозг а геморой
ошибки
Обратите внимание на loaction, книге вообще об этом не гвоорится,и я не знаю,объект ли это,или же член
Error 1 error C2065: 'loaction' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\rect.h 29 Cordination
Error 2 error C2065: 'loaction' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\rect.h 30 Cordination
Error 3 error C2065: 'loaction' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\rect.h 31 Cordination
Error 4 error C2065: 'loaction' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\rect.h 32 Cordination
Error 5 error C2065: 'bottom' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 6 Cordination
Error 6 error C2065: 'bottom' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 16 Cordination
Error 7 error C2065: 'bottom' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 18 Cordination
Error 8 error C2513: 'rectangle' : no variable declared before '=' c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 27 Cordination
Error 9 error C2065: 'MyRectangle' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 28 Cordination
Error 10 error C2228: left of '.GetArea' must have class/struct/union c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 28 Cordination
Error 11 error C3861: 'MyRectangle': identifier not found c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 27 Cordination
Error 12 error C2065: 'cout' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 29 Cordination
Error 13 error C2065: 'MyRectangle' : undeclared identifier c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 29 Cordination
Error 14 error C2228: left of '.GetUpperLeft' must have class/struct/union c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 29 Cordination
Error 15 error C2228: left of '.GetX' must have class/struct/union c:\documents and settings\ag\my documents\visual studio 2008\projects\cordination\cordination\code.cpp 29 Cordination