1183 / 468 / 87
Регистрация: 23.06.2009
Сообщений: 6,390
1

Очень большой геморрой с классами.

19.11.2009, 20:31. Показов 858. Ответов 3
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
вот уже сегодня первый раз написал простенькую программу,мне понравилось,сразу после этого в книге пригигантская программа,которая считывает координаты точек,и в конце выводи площадь прямоуголника...вот коды
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
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
19.11.2009, 20:31
Ответы с готовыми решениями:

Странная ошибка при компиляции очень очень большой проги ,,boomerang,,
Я в общем, даже и не представляю, куда смотреть в поисках ошибки. Ошибка 1 error LNK2019: ссылка...

Очень большой перебор
Всем привет,я новичок,осваиваюсь на C++. В общем,имеется задача. Дано(стандартный ввод) число a(1...

очень большой массив
Здравстуйте! Необходимо решить физическую задачку явной схемой, однако столкнулся с проблемой :...

Работа с очень большой матрицей
Надо постоянно в программе обращаться к матрице большого размера с элементами double...

3
159 / 156 / 47
Регистрация: 29.04.2009
Сообщений: 636
19.11.2009, 20:54 2
половина ошибок неизвестных переменых.
Вторая половина ето выделение объектов неопределенных или необъявленных классов
0
1183 / 468 / 87
Регистрация: 23.06.2009
Сообщений: 6,390
19.11.2009, 20:57  [ТС] 3
Sekt, мда...значит поменять ние невозможно.
0
60 / 60 / 9
Регистрация: 09.11.2009
Сообщений: 198
19.11.2009, 21:26 4
МедведЪ, обратите внимание:
C++
1
void setUpperLeft(point location){itsUpperLeft=loaction;}
- параметр называется location, а в теле функции используется переменная loACtion.
Вы просто не внимательно набирали текст примера.
Еще раз сердито посмотрите на свой код - и Вы сами все исправите!

Добавлено через 2 минуты
если что - спрашивайте (и воздастся вам!)
1
19.11.2009, 21:26
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
19.11.2009, 21:26
Помогаю со студенческими работами здесь

Создать очень большой двумерный массив
всем привет)) нужна матрица очень большая #define M 8000 #define N 8000 double A; //...

Dev-C++: очень большой файл при компиляции
Я перепробовал очень много всяких компиляторов C++ и мне они все не нравились по интерфейсу и т.д....

Как вычислить интеграл, если сама функция вычисляется с очень большой погрешностью? (ужасная точность)
Нужно вычислить интеграл. Но как вычислить интеграл, если сама функция вычисляется с очень большой...

Очень большой CSV
Всем привет. Решил я наконец запились себе БД и уткнулся в проблему. В чем суть. Есть здоровый...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
4
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru