#include
#include
using namespace std;
template
class Point
{
std::tuple args;
public:
Point(Args... a) : args(a...) {}
auto operator(const Point&) const = default;
};
int main()
{
std::cout - это шаблон переменного класса, который имеет конструктор, который принимает вариадические аргументы, которые означает, что компилятор поддерживает точечные конструкторы с различным количеством аргументов.
Например: < /p>
Point p1(1, 2);
Point p2(1, 2, 3);
Point p3(1, 2, 3, 4).
< /code>
Почему я вижу следующие ошибки (ы)? Может ли кто -нибудь помочь понять причину этих ошибок? Я предполагаю, что эти ошибки нуждаются в исправлении в подписи оператора космического корабля. Если да, как я могу это исправить? Заранее спасибо. < /P>
main.cpp: In function ‘int main()’:
main.cpp:29:22: error: no match for ‘operator>=’ (operand types are ‘Point’ and ‘Point’)
29 | std::cout = p2);
| ~~ ^~ ~~
| | |
| | Point
| Point
main.cpp:20:10: note: candidate: ‘auto Point::operator(const Point&) const [with Args = {int, int, int, int}]’ (reversed)
20 | auto operator(const Point&) const = default;
| ^~~~~~~~
main.cpp:20:22: note: no known conversion for argument 1 from ‘Point’ to ‘const Point&’
20 | auto operator(const Point&) const = default;
| ^~~~~~~~~~~~
main.cpp:20:10: note: candidate: ‘auto Point::operator(const Point&) const [with Args = {int, int, int}]’ (rewritten)
20 | auto operator(const Point&) const = default;
| ^~~~~~~~
main.cpp:20:22: note: no known conversion for argument 1 from ‘Point’ to ‘const Point&’
20 | auto operator(const Point&) const = default;
| ^~~~~~~~~~~~
Подробнее здесь: https://stackoverflow.com/questions/796 ... s-template