What's the problem, you have not defined a base class?

SimCard.h
#include "stdafx.h"

class SIMCard
{
private:

 char m_mso; // mobile services operator
 int m_sim; // the presence of the SIM card (1 - true, 0 - no)
 char m_number;

public:
 SIMCard(mso char,int sim, char number)
{
 this->m_mso = mso; 
 this->m_sim = sim;
 this->m_number = number;
}

 void Validate(vector<string>& errors) // check for empty fields
{
 if (NULL == this->m_mso)
 errors.push_back("operator is Not specified");
 if ('0' != this->m_sim && '1' != this->m_sim)
 errors.push_back("Enter 1 - the presence of SIM, 0 - lack");
}

 MSO const char() const // to be called in school etc.
{
 return this->m_mso;
};

 const int Sim() const
{
 return this->m_sim;
};
 const char Number()
{
 return this->m_number;
};

 void operator~()
{
 if (m_sim == 1)
 m_sim = 0;
};

SIMCard();
~SIMCard();
};

MobilePhone.h
#include "stdafx.h"


class MobilePhone: public SIMCard // Phone - a descendant of SIM-cards
{
private:
 char m_vedor; //manufacturer
 char m_model; //model
 int m_price;

public:
 MobilePhone(char vedor, char model, int price)
{
 this->m_model = model; // ukazateli, by private email. to use them in other classes
 this->m_vedor = vedor;
 this->m_price = price;
}

 virtual void Validate(vector<string>& errors) // check for empty fields
{
 if (NULL == this->m_model)
 errors.push_back("No model specified");
 if (NULL == this->m_vedor)
 errors.push_back("unknown manufacturer");
 if (NULL == this->m_price)
 errors.push_back("Enter price of phone");
}

 const char * Model() const // to be called in school etc.
{
 return this->m_model;
};
 const char Vedor() const
{
 return this->m_vedor;
};
 const int Price() const
{
 return this->m_price;
};

MobilePhone();
~MobilePhone();
};



From these two classes inherited flagman and button
flagman.h
#include "Utils.h"

#include "stdafx.h"

Flagmanphone class : public MobilePhone, public SIMCard
{
private:

 Flagmanphone(char mode, char vedor, char mso, int sim, int price, char number) // Announces which fields from the new class
 :MobilePhone(model, vedor, price), SIMCard(mso, sim, number)
{
}

 virtual void Validate(vector<string>& errors)
{
 MobilePhone::Validate(errors); // check the class of the phone
 if (this->Price() < 500)
 errors.push_back("Too low. Flagships are not worth that much");
}
public:


 static MobilePhone* Create()
{
 char model;
 char vedor;
 char mso;
 int sim;
 int price;
 char number;

 if (
 !getValue("Enter model", model) // check for empty values in the file Utils.h
 || !getValue("Enter manufacturer", vedor)
 || !getValue("Enter operator", mso)
 || !getValue("Enter the presence of the sim", sim)
 || !getValue("Enter the price", price)
 || !getValue("Enter phone number", number)
)
{
 return NULL;
}

 Flagmanphone* result = new Flagmanphone(model, vedor, mso, sim, price, number);

 vector<string> errors;
result->Validate(errors);
 if (0 == errors.size())
 return result;

}
Flagmanphone();
~Flagmanphone();
};



When compiling error: SIMCard - not defined base class
March 23rd 20 at 19:43
2 answers
March 23rd 20 at 19:45
Try to add
#include "SimCard.h"
added, it gives an error, see the advertisement SimCard, Mobilephone and all the rest - Minnie.Haley commented on March 23rd 20 at 19:48
While the flagman.h you need to add
#include "MobilePhone.h" - pansy.Armstrong76 commented on March 23rd 20 at 19:51
@pansy.Armstrong76, cm. ad MobilePhone - Minnie.Haley commented on March 23rd 20 at 19:54
@Minnie.Haley, Google "include guards". - rhea.Durg commented on March 23rd 20 at 19:57
March 23rd 20 at 19:47
You need to write
#pragma once
at the beginning of each *.h file. Well, add all the necessary include to all files.

Find more questions by tags C++