Answer:
what are the options?
reply in comment so i can help:)
Answer:
In C++:
#include<iostream>
#include<vector>
using namespace std;
int main(){
int len, num;
vector<int> vect;
cout<<"Length: ";
cin>>len;
for(int i = 0; i<len;i++){
cin>>num;
vect.push_back(num);}
vector<int>::iterator iter;
for (iter = vect.end() - 1; iter >= vect.begin(); iter--){
cout << *iter << ", ";}
}
Explanation:
This declares the length of vector and input number as integer
int len, num;
This declares an integer vector
vector<int> vect;
This prompts the user for length
cout<<"Length: ";
This gets the input for length
cin>>len;
The following iteration gets input into the vector
<em> for(int i = 0; i<len;i++){</em>
<em> cin>>num;</em>
<em> vect.push_back(num);}</em>
This declares an iterator for the vector
vector<int>::iterator iter;
The following iterates from the end to the beginning and prints the vector in reverse
<em> for (iter = vect.end() - 1; iter >= vect.begin(); iter--){</em>
<em> cout << *iter << ", ";}</em>
<em />
<em />
Answer:
Polymorphism
Explanation:
You can have a basic button class that gets inherited by other classes.
class Button {
function pushButton(){}
}
class ElevatorButton extends Button{};
class BigRedButton extends Button{};
With these new classes, they inherit from the basic button class. They can decide what happens when the method pushButton() is called.
You don't need to worry about what pushButton() actually does, you can just call it if the object is of the type "Button" and you can expect it to work.