iMac Pro Processor 2.3GHz, 18-Core Intel Xeon W
Memory 128GB 2666 MHz DDR4
Graphics Radeon Pro9 Vega 64 16GB
OS Catalina 10.15.4
I'm following an online tutorial that has me initializing variables using curly braces rather than parenthesis.
Unfortunately I keep getting the following build error.
At first I thought I was writing the code incorrectly. So I copied the code onto my windows machine and compiled it using the MS Blend IDE. It compiled and ran fine.
Next I assumed it must be the compiler. So I went into the project settings and changed the compiler CLANG. When I built it again the error persisted.
Here is the error I'm getting, followed by my code.
Code: Select all
***************************************
/bin/sh -c '/usr/bin/make -j36 -e -f Makefile'
--------------Building project: [Shipping - Debug ]------------------
/usr/bin/g++ -c "/Users/BeijingCowboy/Programming_Projects/CodeLite_Projects/Shipping/Shipping/main.cpp" -g O0 -Wall -o Debug/main.cpp.o -I. -I./user/bin/g++ -c "/Users/BeijingCowboy/Programming_Projects/CodeLite_Projects/Shipping/Shipping/main.pp:30:14: expected ';' at end of declaration
int length{}, width{}, height{};
^
;
/usr/bin/g++ -c "/Users/BeijingCowboy/Programming_Projects/CodeLite_Projects/Shipping/Shipping/main.cpp:31:21: error: expected ';' at end of declaration
double base_cost{2.50};
^
;
14 errors generated.
make[1]: *** [Debug/main.cpp.o] Error 1
make: *** [All] Error 2
=====15 errors, 0 warnings======
Code: Select all
********************************************
// My code
include <iostream>
using namespace std;
int main()
{
int length{}, width{}, height{};
double base_cost{2.50};
const int tier1_threshold{100}; //volume
const int tier2_threshold{500}; // volume
int max_dimension_length {10}; // inches
double tier1_surcharge{0.10}; // 10% extra
double tier2_surcharge{0.25}; // 25% extra
// All dimensions must be 10 inches or less
int package_volume{};
cout << "Welcome to the package cost calculator" << endl;
cout << "Enter the length, width, and height of the package separated by spaces";
cin >> length >> width >> height;
if (length > max_dimension_length || width > max_dimension_length || height > max_dimension_length){
cout << "Sorry, package rejected - dimension exceeded" << endl;
} else {
cout << "xxx" << endl;}
return 0;
}
*******************************************************