no matching function for call to constructor C++ // не вызывается конструктор в C++
Помогите исправить ошибку
#include <stdio.h>
#include <stdint.h>
using namespace std;
class TEST1
{
public: int a1;
public: TEST1(uint8_t a)
{
this->a1 = a;
};
};
class TEST2
{
public: TEST1 a2;
public: TEST2(uint8_t a)
{
this->a2 = TEST1(a);
};
};
int main()
{
TEST2 test = TEST2(10);
printf("%i", test.a2.a1);
return 0;
};
PS R:\Roma\programing\C or C++\TEST> cd "r:\Roma\programing\C or C++\TEST\" ; if ($?) { g++ main.cpp -o main } ; if ($?) { .\main }
main.cpp: In constructor 'TEST2::TEST2(uint8_t)':
main.cpp:23:5: error: no matching function for call to 'TEST1::TEST1()'
23 | {
| ^
main.cpp:11:13: note: candidate: 'TEST1::TEST1(uint8_t)'
11 | public: TEST1(uint8_t a)
| ^~~~~
main.cpp:11:13: note: candidate expects 1 argument, 0 provided
main.cpp:7:7: note: candidate: 'constexpr TEST1::TEST1(const TEST1&)'
7 | class TEST1
| ^~~~~
main.cpp:7:7: note: candidate expects 1 argument, 0 provided
main.cpp:7:7: note: candidate: 'constexpr TEST1::TEST1(TEST1&&)'
main.cpp:7:7: note: candidate expects 1 argument, 0 provided
PS R:\Roma\programing\C or C++\TEST>