UrzadzenieElektroniczne is my abstract Class and class Komputer inherits from it. I still get errors. I tried to fix them but none of the resolutions I found on the internet worked. Is there a problem with the definition and declaration of my virtual function or should I look for an error somewhere else?: Errors:
1>CKomputer.obj : error LNK2001: unresolved external symbol "public: virtual void__thiscall Komputer::wlaczenieurz(void)" (?wlaczenieurz@Komputer@@UAEXXZ)
#pragma once
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
class UrzadzenieElektroniczne
{
public:
int czy_wlaczony;
UrzadzenieElektroniczne();
~UrzadzenieElektroniczne();
virtual void wlaczenieurz() = 0;
private:
protected:
string producent;
};
#pragma once
#include <stdlib.h>
#include <iostream>
#include <string>
#include "UrzadzenieElektroniczne.h"
#include "Procesor.h"
#include "KartaDzwiekowa.h"
using namespace std;
class Komputer: public UrzadzenieElektroniczne
{
private:
Procesor procesor;
KartaDzwiekowa *karta_dzwiekowa;
string nazwa_komputera;
int ram;
int ile_kart_dzwiekowych;
public:
void wlaczenieurz();
#include <iostream>
#include <cstdio>
#include <string>
#include "CKomputer.h"
#include "Procesor.h"
#include "KartaDzwiekowa.h"
void UrzadzenieElektroniczne::wlaczenieurz()
{
if (czy_wlaczony == 0)
cout<<"Komputer wylaczony"<<endl;
if (czy_wlaczony == 1)
cout<<"Komputer wlaczony"<<endl;
}
Your function should probably be qualified as a member of Komputer
:
void Komputer::wlaczenieurz()
// ^^^^^^^^
{
if (czy_wlaczony == 0)
cout<<"Komputer wylaczony"<<endl;
if (czy_wlaczony == 1)
cout<<"Komputer wlaczony"<<endl;
}