problem z funckcja dziedziczenie

0

witam mam problem z pewna funkcja a mianowicie po odpaleniu wysakuja mi błedy:

C:\Users\glon\Desktop\proooba\code\devik\laptop.h|16|error: variable or field zmien' declared void| C:\Users\glon\Desktop\proooba\code\devik\laptop.h|16|error: expected ;' before '(' token|
== Build finished: 2 errors, 0 warnings ===

oto kod


#include <iostream>
#include "komputer.h"
#include "smartfon.h"
#include "laptop.h"
using namespace std;
using namespace std;
int main()
{
  
   cout<<"komputer PC marki dell: "<<endl;
    komputer dell;
    dell.zapamietaj(3,4);
    dell.wypisz();
    cout<<endl;

 cout<<"komputer PC marki acer: "<<endl;
    
    komputer acer;
    acer.zapamietaj(3,5);
    acer.wypisz();
    cout<<endl;
    
cout<<"Porownanie: "<<endl;
      porownaj_procesory(dell, acer);
     
     porownaj_ramy(dell, acer);
     cout<<endl;
     

 cout<<"Smartfon marki Nokia: "<<endl;    
    smartfon nokia;
    nokia.zapamietaj(92,3,88,44);
  
    nokia.wypisz();
    cout<<endl;
    

 cout<<"Smartfonik marki Ericson: "<<endl;     
     smartfon ericson;
     ericson.zapamietaj(23,3,7,44);
  
    ericson.wypisz();
    cout<<endl;
    
    
    //porownaj//
    
    porownaj_procesory(nokia, ericson);
    porownaj_ramy(nokia, ericson);
    cout<<endl;

    //porownaj// 
    
    laptop lg;
    lg.zapamietaj(2,4,5,6);
    lg.wypisz();
    


////
cout<<endl;
cout<<"po zmianie: "<<endl;
lg.zmien(nokia,104);
nokia.wypisz();



 
    system( "PAUSE" );
    return 0;
}

i laptop.h

#include <iostream>
#ifndef laptop_h
#define laptop_h

class laptop : public komputer
{


   int karta_sim;
   int numer_telefonu;
   int bateria;

public:

 //wpisz x//
      void zmien(smartfon & nokia, int z)
             {
                  nokia.bateria=z;
                  };



    //wpisz//


    laptop(){ }
    void zamknij_pokrywe();

     void  wypisz();
    void zapamietaj(int procesor, int ram,int karta_sim, int bateria);
virtual void uruchom();



};
#endif

Proszę o pomoc, chodzi glownie oto aby funcja zmien zamieniala wartosc baterii w nokii

0

kompilator nie wie czym jest:
smartfon
ja też nie wiem.

0

smartfon.h

#include <iostream>
#ifndef smartfon_h
#define smartfon_h
using namespace std;
class smartfon : public komputer
{
  friend class laptop;
 
   int karta_sim;
   int numer_telefonu;
   int bateria;
   int pole;
public:
    smartfon()
    {}
    
     //porownywanie//
    friend void porownaj_procesory(smartfon & nokia, smartfon & ericson);
    friend void porownaj_ramy(smartfon & nokia, smartfon & ericson);
     friend void porownaj_baterie(smartfon & nokia, smartfon & ericson);
    //porownywanie//
    
   
    void wyswietl();

    void  wypisz();
    void zapamietaj(int procesor, int ram,int karta_sim, int bateria);
    void zadzwon();

    
    
};
#endif

0

A myślisz pewnie że do kompilatora wbudowano proroka Delfijskiego który potrafi zgadnąć że trzeba sięgnąć do pliku:
smartfon.h
po definicje klasy
smartfon
?

0

Masz problem z tymi plikami *.h
Jeżeli laptop.h potrzebuje deklaracji z komputer.h to musisz to dołączyć w laptop.h wtedy jaki nie weźmiesz kompilator to pójdzie.
Niektóre kompilatory robią "prekompilacje" plików nagłówkowych, musisz albo tą prekompilacje wyłączyć albo zrobić po ludzku.

1 użytkowników online, w tym zalogowanych: 0, gości: 1