include iostream include omp include tests HW1Tests cpp class Test pub

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <omp.h>
// #include "tests/HW1Tests.cpp"
class Test {
public:
int val = 0;
Test() {};
};
int f(Test &x) {
return x.val*3;
}
int g(Test &y) {
return y.val+2;
}
using namespace std;
// using namespace tests;
int main() {
Test t;
cout << g(f(t));
return 0;
}
/* ОШИБКИ:
/home/albert/Dropbox/Code/Cpp/CppTasks/src/main.cpp: In function ‘int main()’:
/home/albert/Dropbox/Code/Cpp/CppTasks/src/main.cpp:25:18: error: invalid initialization of non-const reference of type ‘Test&’ from an rvalue of type ‘int’
cout << g(f(t));
^
/home/albert/Dropbox/Code/Cpp/CppTasks/src/main.cpp:16:5: error: in passing argument 1 of ‘int g(Test&)’
int g(Test &y) {
*/