Looking for met2502f25-a.sg test answers and solutions? Browse our comprehensive collection of verified answers for met2502f25-a.sg at distance3.sg.digipen.edu.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Identify C++ keywords in the following function template definition:
template <typename T>
T cube(T value) {
return value*value*value;
}
Which of the following are motivations for C++ to introduce function templates?
Which of the following definitions are scoped enumerations? Choose all appropriate definitions.
Given the following declarations:
enum class CurrencyType {
US_DOLLAR, CAN_DOLLAR, POUND, EURO, YEN, YUAN, RUPEE, MEX_PESO
};
CurrencyType currency;
which of these subsequent statements compile?
Given the following declarations:
enum CurrencyType {
US_DOLLAR, CAN_DOLLAR, POUND, EURO, YEN, YUAN, RUPEE, MEX_PESO
};
CurrencyType currency;
which of these subsequent statements compile?
Given the following code fragment:
void secret(int x, int y, double t, char z = 'A', int n = 67, char v = 'G', double w = 78.34);
int a, b;
char ch;
double d;
// now, we call function secret ...
which of the following calls to function secret evaluate without requiring implicit conversions by the compiler?
Dynamically allocated C++ objects are given storage in a region of program memory called _____________.
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
int &secret(int &a, int b) {
return a += b;
}
// suppose following statements comprise function main ...
int x{};
std::cout << secret(secret(secret(x,3),2),1);
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
int& foo(int x) {
int val {++x};
return val;
}
int boo(int x) {
return x+10;
}
// suppose these statements comprise function main ...
int& ri { foo(10) };
ri = boo(ri);
std::cout << ri;
Write if the following code fragment doesn't compile or write if the code compiles but has undefined behavior when executed. Otherwise, write the exact text written to the standard output stream.
namespace {
int mystery(int&);
}
int main() {
int x{8};
std::array<int, 3> A{0, mystery(x), mystery(x)};
int z{};
for (int y : A) {
z += y;
}
std::cout << z;
}
namespace {
int num{2};
}
namespace {
int mystery(int& y) {
y += (y%2) ? --num : ++num;
return y;
}
}