Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[3.147.89.85] |
|
Сообщ.
#1
,
|
|
|
Собственно, при компиляции С++ - кода (на gcc-4.1.2) файла scientist.cpp выдается ошибка следующего содержания:
scientist.h:1: ошибка: expected class-name before '{' token Содержимое: scientist.cpp #include <iostream> #include "scientist.h" #include "employee.h" void scientist::getdata() { using namespace std; employee emp; emp.getdata(); cout << "Vvedite 4islo publikaciy: "; cin >> pubs; } void scientist::putdata() { using namespace std; employee emp; emp.putdata(); cout << "\n4islo publikaciy: " << pubs; } scientist.h class scientist : public employee{ private: int pubs; public: void getdata(); void putdata(); }; employee.h class employee { private: char name[ 80 ]; int years; public: void getdata(); void putdata(); }; Не бейте меня, я чайнег. |
Сообщ.
#2
,
|
|
|
Dello
а если приинклюдить employee.h перед scientist.h ? а вообще, неверный подход |
Сообщ.
#3
,
|
|
|
О, запахало! Спасибо!
А в чем неверность, если не секрет? |
Сообщ.
#4
,
|
|
|
Dello
я бы как-нибудь так сделал scientist.cpp #include "scientist.h" #include <iostream> void scientist::getdata(){ employee emp; emp.getdata(); std::cout << "Vvedite 4islo publikaciy: "; std::cin >> pubs; } void scientist::putdata(){ employee emp; emp.putdata(); std::cout << "\n4islo publikaciy: " << pubs; } scientist.h #ifndef scientist_h_ #define scientist_h_ #include "employee.h" class scientist : public employee{ private: int pubs; public: void getdata(); void putdata(); }; #endif employee.h #ifndef employee_h_ #define employee_h_ class employee{ private: char name[ 80 ]; int years; public: void getdata(); void putdata(); }; #endif |