Output:
HelloWorld.cpp:4:3: error: ‘PVector’ does not name a type PVector pos; ^~~~~~~ HelloWorld.cpp:5:3: error: ‘PVector’ does not name a type PVector move; ^~~~~~~ HelloWorld.cpp:7:3: error: ‘ArrayList’ does not name a type ArrayList<Boid> friends; ^~~~~~~~~ HelloWorld.cpp:102:3: error: ‘PVector’ does not name a type PVector getAverageDir () { ^~~~~~~ HelloWorld.cpp:123:3: error: ‘PVector’ does not name a type PVector getAvoidDir() { ^~~~~~~ HelloWorld.cpp:145:3: error: ‘PVector’ does not name a type PVector getAvoidAvoids() { ^~~~~~~ HelloWorld.cpp:164:3: error: ‘PVector’ does not name a type PVector getCohesion () { ^~~~~~~ HelloWorld.cpp:214:2: error: expected ‘;’ after class definition } ^ ; HelloWorld.cpp: In constructor ‘Boid::Boid(float, float)’: HelloWorld.cpp:14:5: error: ‘move’ was not declared in this scope move = new PVector(0, 0); ^~~~ HelloWorld.cpp:14:5: note: suggested alternative: In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from HelloWorld.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:479:5: note: ‘std::move’ move(_II __first, _II __last, _OI __result) ^~~~ HelloWorld.cpp:14:16: error: expected type-specifier before ‘PVector’ move = new PVector(0, 0); ^~~~~~~ HelloWorld.cpp:15:5: error: ‘pos’ was not declared in this scope pos = new PVector(0, 0); ^~~ HelloWorld.cpp:15:15: error: expected type-specifier before ‘PVector’ pos = new PVector(0, 0); ^~~~~~~ HelloWorld.cpp:18:31: error: too many arguments to function ‘long int random()’ thinkTimer = int(random(10)); ^ In file included from /usr/include/c++/7/cstdlib:75:0, from /usr/include/c++/7/ext/string_conversions.h:41, from /usr/include/c++/7/bits/basic_string.h:6361, from /usr/include/c++/7/string:52, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from HelloWorld.cpp:1: /usr/include/stdlib.h:401:17: note: declared here extern long int random (void) __THROW; ^~~~~~ HelloWorld.cpp:19:23: error: too many arguments to function ‘long int random()’ shade = random(255); ^ In file included from /usr/include/c++/7/cstdlib:75:0, from /usr/include/c++/7/ext/string_conversions.h:41, from /usr/include/c++/7/bits/basic_string.h:6361, from /usr/include/c++/7/string:52, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from HelloWorld.cpp:1: /usr/include/stdlib.h:401:17: note: declared here extern long int random (void) __THROW; ^~~~~~ HelloWorld.cpp:20:5: error: ‘friends’ was not declared in this scope friends = new ArrayList<Boid>(); ^~~~~~~ HelloWorld.cpp:20:5: note: suggested alternative: ‘fread’ friends = new ArrayList<Boid>(); ^~~~~~~ fread HelloWorld.cpp:20:19: error: ‘ArrayList’ does not name a type friends = new ArrayList<Boid>(); ^~~~~~~~~ HelloWorld.cpp:20:33: error: expected primary-expression before ‘>’ token friends = new ArrayList<Boid>(); ^ HelloWorld.cpp:20:35: error: expected primary-expression before ‘)’ token friends = new ArrayList<Boid>(); ^ HelloWorld.cpp: In member function ‘void Boid::go()’: HelloWorld.cpp:32:5: error: ‘pos’ was not declared in this scope pos.add(move); ^~~ HelloWorld.cpp:32:13: error: ‘move’ was not declared in this scope pos.add(move); ^~~~ HelloWorld.cpp:32:13: note: suggested alternative: In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from HelloWorld.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:479:5: note: ‘std::move’ move(_II __first, _II __last, _OI __result) ^~~~ HelloWorld.cpp: In member function ‘void Boid::flock()’: HelloWorld.cpp:36:5: error: ‘PVector’ was not declared in this scope PVector allign = getAverageDir(); ^~~~~~~ HelloWorld.cpp:37:13: error: expected ‘;’ before ‘avoidDir’ PVector avoidDir = getAvoidDir(); ^~~~~~~~ HelloWorld.cpp:38:13: error: expected ‘;’ before ‘avoidObjects’ PVector avoidObjects = getAvoidAvoids(); ^~~~~~~~~~~~ HelloWorld.cpp:39:13: error: expected ‘;’ before ‘noise’ PVector noise = new PVector(random(2) - 1, random(2) -1); ^~~~~ HelloWorld.cpp:40:13: error: expected ‘;’ before ‘cohese’ PVector cohese = getCohesion(); ^~~~~~ HelloWorld.cpp:42:5: error: ‘allign’ was not declared in this scope allign.mult(1); ^~~~~~ HelloWorld.cpp:42:5: note: suggested alternative: ‘alloca’ allign.mult(1); ^~~~~~ alloca HelloWorld.cpp:43:10: error: ‘option_friend’ was not declared in this scope if (!option_friend) allign.mult(0); ^~~~~~~~~~~~~ HelloWorld.cpp:45:5: error: ‘avoidDir’ was not declared in this scope avoidDir.mult(1); ^~~~~~~~ HelloWorld.cpp:45:5: note: suggested alternative: ‘void’ avoidDir.mult(1); ^~~~~~~~ void HelloWorld.cpp:46:10: error: ‘option_crowd’ was not declared in this scope if (!option_crowd) avoidDir.mult(0); ^~~~~~~~~~~~ HelloWorld.cpp:48:5: error: ‘avoidObjects’ was not declared in this scope avoidObjects.mult(3); ^~~~~~~~~~~~ HelloWorld.cpp:49:10: error: ‘option_avoid’ was not declared in this scope if (!option_avoid) avoidObjects.mult(0); ^~~~~~~~~~~~ HelloWorld.cpp:51:5: error: ‘noise’ was not declared in this scope noise.mult(0.1); ^~~~~ HelloWorld.cpp:52:10: error: ‘option_noise’ was not declared in this scope if (!option_noise) noise.mult(0); ^~~~~~~~~~~~ HelloWorld.cpp:54:5: error: ‘cohese’ was not declared in this scope cohese.mult(1); ^~~~~~ HelloWorld.cpp:55:10: error: ‘option_cohese’ was not declared in this scope if (!option_cohese) cohese.mult(0); ^~~~~~~~~~~~~ HelloWorld.cpp:57:5: error: ‘stroke’ was not declared in this scope stroke(0, 255, 160); ^~~~~~ HelloWorld.cpp:57:5: note: suggested alternative: ‘stdout’ stroke(0, 255, 160); ^~~~~~ stdout HelloWorld.cpp:59:5: error: ‘move’ was not declared in this scope move.add(allign); ^~~~ HelloWorld.cpp:59:5: note: suggested alternative: In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from HelloWorld.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:479:5: note: ‘std::move’ move(_II __first, _II __last, _OI __result) ^~~~ HelloWorld.cpp:65:16: error: ‘maxSpeed’ was not declared in this scope move.limit(maxSpeed); ^~~~~~~~ HelloWorld.cpp:68:23: error: too many arguments to function ‘long int random()’ shade += (random(2) - 1) ; ^ In file included from /usr/include/c++/7/cstdlib:75:0, from /usr/include/c++/7/ext/string_conversions.h:41, from /usr/include/c++/7/bits/basic_string.h:6361, from /usr/include/c++/7/string:52, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from HelloWorld.cpp:1: /usr/include/stdlib.h:401:17: note: declared here extern long int random (void) __THROW; ^~~~~~ HelloWorld.cpp:69:27: error: invalid operands of types ‘float’ and ‘int’ to binary ‘operator%’ shade = (shade + 255) % 255; //max(0, min(255, shade)); ~~~~~~~~~~~~~~^~~~~ HelloWorld.cpp: In member function ‘void Boid::getFriends()’: HelloWorld.cpp:73:5: error: ‘ArrayList’ was not declared in this scope ArrayList<Boid> nearby = new ArrayList<Boid>(); ^~~~~~~~~ HelloWorld.cpp:73:19: error: expected primary-expression before ‘>’ token ArrayList<Boid> nearby = new ArrayList<Boid>(); ^ HelloWorld.cpp:73:21: error: ‘nearby’ was not declared in this scope ArrayList<Boid> nearby = new ArrayList<Boid>(); ^~~~~~ HelloWorld.cpp:73:34: error: ‘ArrayList’ does not name a type ArrayList<Boid> nearby = new ArrayList<Boid>(); ^~~~~~~~~ HelloWorld.cpp:73:48: error: expected primary-expression before ‘>’ token ArrayList<Boid> nearby = new ArrayList<Boid>(); ^ HelloWorld.cpp:73:50: error: expected primary-expression before ‘)’ token ArrayList<Boid> nearby = new ArrayList<Boid>(); ^ HelloWorld.cpp:74:24: error: ‘boids’ was not declared in this scope for (int i =0; i < boids.size(); i++) { ^~~~~ HelloWorld.cpp:74:24: note: suggested alternative: ‘Boid’ for (int i =0; i < boids.size(); i++) { ^~~~~ Boid HelloWorld.cpp:76:16: error: no match for ‘operator==’ (operand types are ‘Boid’ and ‘Boid*’) if (test == this) continue; ~~~~~^~~~~~~ HelloWorld.cpp:77:20: error: ‘class Boid’ has no member named ‘pos’ if (abs(test.pos.x - this.pos.x) < friendRadius && ^~~ HelloWorld.cpp:77:33: error: request for member ‘pos’ in ‘(Boid*)this’, which is of pointer type ‘Boid*’ (maybe you meant to use ‘->’ ?) if (abs(test.pos.x - this.pos.x) < friendRadius && ^~~ HelloWorld.cpp:77:42: error: ‘friendRadius’ was not declared in this scope if (abs(test.pos.x - this.pos.x) < friendRadius && ^~~~~~~~~~~~ HelloWorld.cpp:78:18: error: ‘class Boid’ has no member named ‘pos’ abs(test.pos.y - this.pos.y) < friendRadius) { ^~~ HelloWorld.cpp:78:31: error: request for member ‘pos’ in ‘(Boid*)this’, which is of pointer type ‘Boid*’ (maybe you meant to use ‘->’ ?) abs(test.pos.y - this.pos.y) < friendRadius) { ^~~ HelloWorld.cpp:82:5: error: ‘friends’ was not declared in this scope friends = nearby; ^~~~~~~ HelloWorld.cpp:82:5: note: suggested alternative: ‘fread’ friends = nearby; ^~~~~~~ fread HelloWorld.cpp: In member function ‘float Boid::getAverageColor()’: HelloWorld.cpp:88:23: error: ‘friends’ was not declared in this scope for (Boid other : friends) { ^~~~~~~ HelloWorld.cpp:88:23: note: suggested alternative: ‘fread’ for (Boid other : friends) { ^~~~~~~ fread HelloWorld.cpp: In member function ‘void Boid::draw()’: HelloWorld.cpp:187:26: error: ‘friends’ was not declared in this scope for ( int i = 0; i < friends.size(); i++) { ^~~~~~~ HelloWorld.cpp:187:26: note: suggested alternative: ‘fread’ for ( int i = 0; i < friends.size(); i++) { ^~~~~~~ fread HelloWorld.cpp:189:7: error: ‘stroke’ was not declared in this scope stroke(90); ^~~~~~ HelloWorld.cpp:189:7: note: suggested alternative: ‘stdout’ stroke(90); ^~~~~~ stdout HelloWorld.cpp:192:5: error: ‘noStroke’ was not declared in this scope noStroke(); ^~~~~~~~ HelloWorld.cpp:193:5: error: ‘fill’ was not declared in this scope fill(shade, 90, 200); ^~~~ HelloWorld.cpp:193:5: note: suggested alternative: In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from HelloWorld.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:724:5: note: ‘std::fill’ fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) ^~~~ HelloWorld.cpp:194:5: error: ‘pushMatrix’ was not declared in this scope pushMatrix(); ^~~~~~~~~~ HelloWorld.cpp:195:15: error: ‘pos’ was not declared in this scope translate(pos.x, pos.y); ^~~ HelloWorld.cpp:195:5: error: ‘translate’ was not declared in this scope translate(pos.x, pos.y); ^~~~~~~~~ HelloWorld.cpp:196:12: error: ‘move’ was not declared in this scope rotate(move.heading()); ^~~~ HelloWorld.cpp:196:12: note: suggested alternative: In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from HelloWorld.cpp:1: /usr/include/c++/7/bits/stl_algobase.h:479:5: note: ‘std::move’ move(_II __first, _II __last, _OI __result) ^~~~ HelloWorld.cpp:196:5: error: ‘rotate’ was not declared in this scope rotate(move.heading()); ^~~~~~ HelloWorld.cpp:196:5: note: suggested alternative: ‘rename’ rotate(move.heading()); ^~~~~~ rename HelloWorld.cpp:197:5: error: ‘beginShape’ was not declared in this scope beginShape(); ^~~~~~~~~~ HelloWorld.cpp:198:17: error: ‘globalScale’ was not declared in this scope vertex(15 * globalScale, 0); ^~~~~~~~~~~ HelloWorld.cpp:198:5: error: ‘vertex’ was not declared in this scope vertex(15 * globalScale, 0); ^~~~~~ HelloWorld.cpp:201:14: error: ‘CLOSE’ was not declared in this scope endShape(CLOSE); ^~~~~ HelloWorld.cpp:201:5: error: ‘endShape’ was not declared in this scope endShape(CLOSE); ^~~~~~~~ HelloWorld.cpp:201:5: note: suggested alternative: ‘unshare’ endShape(CLOSE); ^~~~~~~~ unshare HelloWorld.cpp:202:5: error: ‘popMatrix’ was not declared in this scope popMatrix(); ^~~~~~~~~ HelloWorld.cpp: In member function ‘void Boid::wrap()’: HelloWorld.cpp:211:5: error: ‘pos’ was not declared in this scope pos.x = (pos.x + width) % width; ^~~ HelloWorld.cpp:211:22: error: ‘width’ was not declared in this scope pos.x = (pos.x + width) % width; ^~~~~ HelloWorld.cpp:211:22: note: suggested alternative: ‘wcwidth’ pos.x = (pos.x + width) % width; ^~~~~ wcwidth HelloWorld.cpp:212:22: error: ‘height’ was not declared in this scope pos.y = (pos.y + height) % height; ^~~~~~
Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++
and start coding!
OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.
C++ is a widely used middle-level programming language.
When ever you want to perform a set of operations based on a condition If-Else is used.
You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.
Switch is an alternative to If-Else-If ladder.
For loop is used to iterate a set of statements based on a condition.
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.