Я понятия не имею, что происходит. Мне нужно закончить это до полуночи завтра, и по какой -либо причине это не сработает.#include
#include
#include "heart.h"
Heart::Heart(int v){
SetValue(v);
SetColor("red");
SetSuit('H');
}
string Heart::Description() const
// Good ol' fashioned copy-n'-paste...
// You know you love it.
{
string d = "Value = "; // temporary variable used to accumulate result
int Value = GetValue(); // A bit more complicated than I expected, but only a line's worth of difference after debugging.
switch (Value) // Append card value to variable's value
{
case 2: d = d + "2"; break; // Number cards
case 3: d = d + "3"; break;
case 4: d = d + "4"; break;
case 5: d = d + "5"; break;
case 6: d = d + "6"; break;
case 7: d = d + "7"; break;
case 8: d = d + "8"; break;
case 9: d = d + "9"; break;
case 10: d = d + "10"; break;
case 11: d = d + "J"; break; // Face cards
case 12: d = d + "Q"; break;
case 13: d = d + "K"; break;
case 14: d = d + "A"; break;
default: d = d + "?"; break; // Unknown card
}
d = d + ", Color = " + GetColor(); // Hm, hm...
d = d + ", Suit = " + GetSuit(); // Further than that, the suits were ALSO copy-pasted from the color-cards, in their entirety!!
return d; // Return string describing card value
}
< /code>
Просто игнорируйте комментарии, я делаю это для класса колледжа.
Попытка компилировать, я получаю эту ошибку: < /p>
g++ -c heart.cpp
heart.cpp: In constructor ‘Heart::Heart(int)’:
heart.cpp:5:19: error: no matching function for call to ‘RedCard::RedCard()’
Heart::Heart(int v){
^
In file included from heart.h:10,
from heart.cpp:3:
redcard.h:19:3: note: candidate: ‘RedCard::RedCard(int)’
RedCard(int v); // Creates a red card with value v and unknown suit
^~~~~~~
redcard.h:19:3: note: candidate expects 1 argument, 0 provided
redcard.h:12:7: note: candidate: ‘RedCard::RedCard(const RedCard&)’
class RedCard : public Card
^~~~~~~
redcard.h:12:7: note: candidate expects 1 argument, 0 provided
redcard.h:12:7: note: candidate: ‘RedCard::RedCard(RedCard&&)’
redcard.h:12:7: note: candidate expects 1 argument, 0 provided
make: *** [makefile:24: heart.o] Error 1
< /code>
В этом файле нет вызова Redcard, это все в его отдельном файле.
на всякий случай, вот Heart.h < /p>
//
// heart.h -- CPE 212 -- Project02 -- Classes + Inheritance
//
// DO NOT MODIFY OR SUBMIT THIS FILE!!!
//
#ifndef HEART_H
#define HEART_H
#include "redcard.h"
class Heart : public RedCard
{
private:
// No additional private members
public:
// Constructors
Heart(int v); // Creates a red heart card with value v
string Description() const; // Outputs card characteristics - value, color, suit
// Hint: use base class Description method to generate part of
// the description and append the suit information at the end
};
#endif
< /code>
redcard.h
//
// redcards.h -- CPE 212 -- Project02 -- Classes + Inheritance
//
// DO NOT MODIFY OR SUBMIT THIS FILE!!!
//
#ifndef REDCARD_H
#define REDCARD_H
#include "card.h"
class RedCard : public Card
{
private:
// No additional private members
public:
// Constructors
RedCard(int v); // Creates a red card with value v and unknown suit
string Description() const; // Outputs card characteristics - value and color as a string
// Hint: use base class Description method to generate part of
// the description and append the color information at the end
};
#endif
< /code>
redcard.cpp (это просто в порядке) < /p>
#include
#include
#include "redcard.h"
RedCard::RedCard(int v){
SetValue(v);
SetColor("red");
SetSuit('U');
}
string RedCard::Description() const
// Good ol' fashioned copy-n'-paste...
// You know you love it.
{
string d = "Value = "; // temporary variable used to accumulate result
int Value = GetValue(); // A bit more complicated than I expected, but only a line's worth of difference after debugging.
switch (Value) // Append card value to variable's value
{
case 2: d = d + "2"; break; // Number cards
case 3: d = d + "3"; break;
case 4: d = d + "4"; break;
case 5: d = d + "5"; break;
case 6: d = d + "6"; break;
case 7: d = d + "7"; break;
case 8: d = d + "8"; break;
case 9: d = d + "9"; break;
case 10: d = d + "10"; break;
case 11: d = d + "J"; break; // Face cards
case 12: d = d + "Q"; break;
case 13: d = d + "K"; break;
case 14: d = d + "A"; break;
default: d = d + "?"; break; // Unknown card
}
d = d + ", Color = " + GetColor(); // And that's the only difference.
return d; // Return string describing card value
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... d-function
"Нет совпадения функции для Call", когда я не вызываю именованную функцию ⇐ C++
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Не можете вернуть именованную ссылку RVALUE в функции с возвращающимся типом ссылки LVALUE?
Anonymous » » в форуме C++ - 0 Ответы
- 17 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Почему бросает ошибку в еще не гадающую асинхронную функцию Call Call Node.js?
Anonymous » » в форуме Javascript - 0 Ответы
- 17 Просмотры
-
Последнее сообщение Anonymous
-