Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

why does my code still have 4 errors in the ( int main ) section and will not run in eclipse? #include #include using namespace

why does my code still have 4 errors in the (int main) section and will not run in eclipse?
#include
#include
using namespace std;
void countUp(){
int i;
for(i =0; i <=20; i++){
cout << i << endl;
}
}
void countDown(){
int i;
for(i =19; i >=0; i--){
cout << i << endl;
}
}
int main(){
thread countUpThread(countUp);
countUpThread.join();
thread countDownThread(countDown);
countDownThread.join();
return 0;
}
here are the errors that I keep getting
..\src\Module7Porfolio.cpp:27:4: error: 'thread' was not declared in this scope
thread countUpThread(countUp);
^~~~~~
..\src\Module7Porfolio.cpp:28:4: error: 'countUpThread' was not declared in this scope
countUpThread.join();
^~~~~~~~~~~~~
..\src\Module7Porfolio.cpp:29:11: error: expected ';' before 'countDownThread'
thread countDownThread(countDown);
^~~~~~~~~~~~~~~
..\src\Module7Porfolio.cpp:30:4: error: 'countDownThread' was not declared in this scope
countDownThread.join();
^~~~~~~~~~~~~~~
14:50:14 Build Failed. 4 errors, 0 warnings. (took 826ms)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions