Форум русскоязычного сообщества Ubuntu


Увидели сообщение с непонятной ссылкой, спам, непристойность или оскорбление?
Воспользуйтесь ссылкой «Сообщить модератору» рядом с сообщением!

Автор Тема: g++ и компиляция  (Прочитано 2122 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн int1k

  • Автор темы
  • Новичок
  • *
  • Сообщений: 31
    • Просмотр профиля
g++ и компиляция
« : 25 Октября 2009, 16:49:00 »
делаю проект по инфоматике. Длинная арифметика. Под виндой когда-то делал, вот в инсте сказали. Делаю уже не через массив, а через списки
при компиляции вылезают ошибки
mike@nitrogenium:~/longmath$ g++ longint.h longint.cpp main.cpp -o longmath && ./longmath
longint.cpp: In member function ‘int* LongInt::size()’:
longint.cpp:13: error: request for member ‘fdig’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp:15: error: request for member ‘sz’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp:16: error: no match for ‘operator!=’ in ‘* p != 0’
longint.cpp:18: error: request for member ‘next’ in ‘p’, which is of non-class type ‘digit*’
longint.cpp:19: error: request for member ‘sz’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp:22: error: request for member ‘sz’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp: In constructor ‘LongInt::LongInt()’:
longint.cpp:28: error: request for member ‘prev’ in ‘((LongInt*)this)->LongInt::fdig’, which is of non-class type ‘digit*’
longint.cpp:29: error: request for member ‘next’ in ‘((LongInt*)this)->LongInt::fdig’, which is of non-class type ‘digit*’
longint.cpp:30: error: request for member ‘sign’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp:31: error: request for member ‘sz’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp:32: error: request for member ‘sz’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp: In destructor ‘LongInt::~LongInt()’:
longint.cpp:37: error: request for member ‘size’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp:39: error: request for member ‘sz’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp:41: error: request for member ‘sz’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp:45: error: request for member ‘fdig’ in ‘this’, which is of non-class type ‘LongInt* const’
longint.cpp:46: error: ISO C++ forbids comparison between pointer and integer
longint.cpp:48: error: request for member ‘next’ in ‘p’, which is of non-class type ‘digit*’
longint.cpp:49: error: request for member ‘prev’ in ‘p’, which is of non-class type ‘digit*’
longint.cpp:52: error: request for member ‘sz’ in ‘this’, which is of non-class type ‘LongInt* const’
Я не понимаю почему, объясните. Программировал давно, возможно  я ошибаюсь даже в самом коде.
Код соотв на http://dev.int1k.ru/projects/longmath/
« Последнее редактирование: 25 Октября 2009, 16:55:01 от int1k »

Оффлайн Sova777

  • Участник
  • *
  • Сообщений: 208
    • Просмотр профиля
    • Несколько слов о NetBeans C/C++ Pack'е
Re: g++ и компиляция
« Ответ #1 : 25 Октября 2009, 17:45:31 »
Код странновато выглядит.
Идеологическии странности:
1) g++ longint.h longint.cpp main.cpp
2) код в longint.cpp
#ifndef LONGINT_CPP
#define LONGINT_CPP
...
#endif
Пользователь OpenSolaris 2008.11, Ubuntu 8.10, Windows XP. Mac OS X не нравится, стараюсь не использовать.

Оффлайн int1k

  • Автор темы
  • Новичок
  • *
  • Сообщений: 31
    • Просмотр профиля
Re: g++ и компиляция
« Ответ #2 : 25 Октября 2009, 17:51:52 »
убрал в коде this и теперь все работает. правда утечка памяти=)

 

Страница сгенерирована за 0.016 секунд. Запросов: 21.