Witam. Chcę zaprzyjaźnić wzejemnie ze sobą 2 klasy jednak nie za bardzo mi to wyszło. Czy mógłby ktoś sprawdzić czy wszystko zadeklarowałem w odpowiedniej koleiności bo pierwszy raz robie coś takiego.
Ponad to wyrzuca mi błędy
14 linijka pliku.h expected class name before '(' token
14 linijka pliku.h expected '{' before '(' token
i jescze 46 linijka pliku.h two or more datatypes in declaration set_mode
#ifndef TV_H
#define TV_H
class Tv;
class Remote
{
private :
friend class Tv;
int mode;
int tryb;
public:
enum {Zwykly,Interaktywny};
enum {TV,DVD};
Remote(int m=TV,int t=Interaktywny): Remote::mode(m),Remote::tryb(t){}
bool volup(Tv& t);
bool voldown(Tv& t);
void onoff(Tv& t);
void chanup(Tv& t);
void chandown(Tv& t);
void set_chan(Tv&t,int c);
void set_mode(Tv& t);
void set_input(Tv&t);
void show();
};
class Tv
{
friend class Remote;
public:
enum{Off,On};
enum{MinVal,MaxVal=20};
enum{Antenna,Cable}; //przez 2n
enum {TV,DVD};
Tv (int s=Off,int mc=125):state(s),volume(5),maxchannel(mc),channel(2),mode(Cable),input(TV){}
void onoff(){state=(state==On) ? Off:On;}
bool ison(){return state==On;}
bool volup();
bool voldown();
void chanup();
void chandown();class Remote
void set_mode(){Tv::mode=(Tv::mode==Antenna)? Cable:Antenna;}
void set_input(){input=(input==TV) ? DVD:TV;}
void settings() const;
void change(Remote& r); // zmienia atrybut klasy Remote
private:
int state;
int volume;
int maxchannel;
int channel;
int mode;
int input;
};
#endif // TV_H
#include"TV.h"
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
bool Tv::volup()
{
if (volume==MaxVal)
return false;
else {volume++; return true;}
}
bool Tv::voldown()
{
if (volume==MinVal)
return false;
else {volume--; return true;}
}
void Tv::chanup()
{
if (channel==maxchannel)
channel=1;
else{channel++;}
}
void Tv::chandown()
{
if (channel==1)
channel=maxchannel;
else{channel--;}
}
void Tv::settings() const
{
cout<<"Telewizor jest "<<(state==Off? "OFF":"ONN")<<endl;
if(state==On)
{
cout<<"Glosnosc "<<volume<<endl;
cout<<"Program "<<channel<<endl;
cout<<"Mode "<<(mode==Antenna ? "Antena":"Kabel")<<endl;
cout<<"Wejscie "<<(input==TV ? "TV":"DVD")<<endl;
}
}
void Tv::change(Remote& r)
{
r.tryb=(r.tryb==Interaktywny? Zwykly:Interaktywny ;)
}
bool Remote::volup(Tv& t)
{return t.volup();}
bool Remote::voldown(Tv& t)
{return t.voldown();}
void Remote::onoff(Tv& t)
{t.onoff();}
void Remote::chanup(Tv& t)
{t.chanup();}
void Remote::chandown(Tv& t)
{t.chandown();}
void Remote::set_chan(Tv&t,int c)
{t.channel=c;}
void Remote::set_mode(Tv& t)
{t.set_mode();}
void Remote::set_input(Tv&t)
{t.set_input();}
void Remote::show()
{
cout<<"Tryb "<<(tryb==Interaktywny ? "Interaktywny":"Zwykly")<<endl;
}