How many syntax errors in the following code? Assume all libraries are including
question 4
There are four syntax errors in the code.
the resolved code
class ShapeType
{
protected:
double length, width;
public:
void setDimension (double l, double w) { length = l; width = w; }
void print()
};
class rectangleType: protected ShapeType
{
private:
public:
double length, width;
rectangleType() {length = 0; width = 0;}
rectangleType(double L, double W) {
setDimension(L, W);
}
void setDimension(double L, double w) {
length = L;
width = w;
}
double getLength() { return length; }
double getwidth() { return width; }
double area() { return length * width; }
double perimeter() { return 2 * (length + width); }
void print() {
ShapeType::print();
cout << "Length: " << length << endl;
cout << "Width: " << width << endl;
cout << "Area: " << area() << endl;
cout << "Perimeter: " << perimeter() << endl;
}
question 5
A. Templates in C++ are commonly used to repeat code by generating a set of classes and functions
B. Friend functions are member functions that have the right to access public and protected member functions.
D. Overloading an operator is commonly used to change its precedence
E. It is possible to create new operators in C++
F. We can override built-in type operators in C++
question 6
C. We give the highest priority to the first element in the STL's priority queue
E. Memory addresses store integers that can point other integers
Step by step
Solved in 2 steps