C ++ questions. 1) Fill in the blanks. a) STL algorithms work indirectly using ______ on container elements. b) A ______ data member contains information belonging to the class. 2) Fix bugs and potential flaws in this code. #include int main() { vector coordinates; coordinates.push_back(34); coordinates.push_back(768); coordinates.push_back(516); coordinates.push_back(834); for(auto it = coordinates.begin(); it != coordinates.end(); it++) if(*it == 768) coordinates.erase(it); for(auto& coordinate : coordinates) cout << coordinate << ", "; cout << '\n'; return 0; } 3) Being able to point to a derived class object with a base class pointer is a result of the ISA relationship. True or False?
Q: As of C++11, you can ask a vector or deque to return unneeded memory to the system by calling member…
A: Given Data:- As of C++11, you can ask a vector or deque to return unneeded memory to the system by…
Q: serial number, category, and price. You are supposed to do the following with this same. So 16.…
A: I have used c++ to define the requirements. So 16. Define a appropriate structure to manage this…
Q: A Bounding Box is simply a rectangle used to enclose a two-dimensional shape. Bounding boxes are…
A: Dear Student the 3 lines for bound box algorithm for collision detection is given below the lines…
Q: c++ Modify the following so that it uses smart pointers instead of raw pointers. // This program…
A: Solution :: Program: Salary import java.io.BufferedWriter; import java.io.File; import…
Q: 1. Define a struct for employees The struct should include the following fields: name, which should…
A: According the information given:- We have to define a struct for employee, with initialize single…
Q: You are working for a university to maintain a list of grades and some related statistics for a…
A: According to the information given:- We have to create c++ program to maintain a list of grades and…
Q: Computer Science I need a program written in C++, This program will read the words i entered, till…
A: I have provided C++ CODE along with CODE SCREENSHOT and also provided OUTPUT…
Q: C code Blocks Write the complete function that receives a pointer to the array's first element as…
A: Here we need to multiply 3rd element by 10. Now we need to select the third element, and in the…
Q: Exercise 3- Exercise Objectives V Manipulating strings using pointers Problem Description Write and…
A: Below is the required C program: - Approach: - Include the header files. Define the function…
Q: 10.15 LAB: Plant information (vector) C++ Given a base Plant class and a derived Flower class,…
A: Program Plan:- Initialize all the header files. Create the plant.h and define all the setter and…
Q: c++ Here are struct data members: integer for the ID of a student character array for the name.…
A: The code is given below.
Q: I wanna help in this 2 OPERATOR using c++ . (This is the header of question) (Create a class…
A: C++ PROGRAM: #include <iostream>using namespace std;class IntegerSet{private:int set[ 101…
Q: Card Shuffling and Dealing (CH) o Create a program to shuffle and deal a deck of cards. o The…
A: Step 1:- Program Approach:- 1.Include header file 2.Create the class Card 3.Create the class…
Q: Write a program that inputs, processes, and outputs a set of student records organized as a vector…
A: First, we will create a structure named StudentRec. Then we will add students records accordingly…
Q: 9.12: Element Shifter C++Write a function that accepts an int array and the array’s size as…
A: A C++ program for the given criteria is as follows, File name: “main.cpp” #include<iostream>…
Q: c++ ABC Central Library has hundreds of books which needs to be managed. Librarians who are experts…
A: As per our guidelines we are suppose to answer only first question. Kindly repost other question…
Q: Topical Information Use C++. The purpose of this project is to test your ability to use templates,…
A: PROGRAM: #include <iostream> #include <cassert> using namespace std; //dynamic array…
Q: Assume you have a vector defined in C++ STL as vector myvector; What command will add elements to…
A: push_back() is used to add elements to the vector. Code: #include <iostream> #include…
Q: Assume that you have the following definition of a struct. struct partsType { int partNum; double…
A: C++ programming language is used for the below program in step2: The structure is a user-defined…
Q: C++ ************Comment code please************ Into two files, p1.h and p1.cpp, create a class…
A: Answer: C++ Source Code: p1.cpp: #include "p1.h" int main() { int…
Q: rite C++ functions, class and methods to answer the following question. Write a function named…
A: the c++ program is an given below :
Q: PHP Write a modeMaker function Write a function modeMaker() that forms a closure such that the…
A: Solution:-- 1)The question has required for the solution which is to be provided in the form of…
Q: 9.12: Element Shifter Write a function that accepts an int array and the array’s size as arguments.…
A: A C++ program for the given criteria is as follows, File name: “main.cpp” #include<iostream>…
Q: Using the attached code as a model, write a program where each student record is a structure that…
A: We will create a structure named StudentRec and then we will add students records accordingly and…
Q: C++ Program You may use the vector and iostream libraries. You are allowed to use three built-in…
A: C++ Program You may use the vector and iostream libraries. You are allowed to use three built-in…
Q: Case - IV: Structs A UOG Fast Food Shop has menu of items being sold on point. Each item has serial…
A: I have defined the above requirements in c++. //SQ.16struct Shop{ int SNO; string name;…
Q: using c++ .Assuming you have a class Student 1- Implement the class constructor and print member…
A: Hi, As we are allowed to answer only 3 multi-parts in one question, I request you to upload other…
Q: Create a struct called Complex for performing arithmetic with complex numbers. Write a driver…
A: void::Complex print. There should be a condition inside cout itself. No if-else. But I have no idea…
Q: Template Specialization in c++ is used to write generic code. Template code is written once and use…
A: Coded using C++.
Q: In C++, Define struct StudentInfo; maintain records in a vector. Program prompts for and fetches…
A: we need to find max and minimum grade using structure and vector concept in c++
Q: (a)(i) Create a City structure that will have the following members: name (string type), population…
A: The problem is pretty much justified all the function name and desired output is mentioned. Since no…
Q: lease continue tthe code below --- #include
A: #include <stdio.h>#include<conio.h> struct Employee { // declaring the members of…
Q: 1- Define a struct type that contains a person’s name consisting of a first name and a second name,…
A: Purpose of the problem:This program can be used to create an array of structures for capturing data…
Q: QI Typing linspace ( start point, end point) will generate a vector of -------?
A: The function linespace in matlab return vector of 100 evenly spaced points, hence option (a), (c)…
Q: 1. Write a function named “getSumBeforeNegative” that takes in a pointer to the array of integers…
A: Given: 1. Write a function named “getSumBeforeNegative” that takes in a pointer to the array of…
Q: OOP using C++ please give me full answer thanks : A designer in 3D graphics company wants to…
A: Program approach:- Using the necessary header file. Using the standard namespace I/O. Constructors…
Q: main.c I am so mad at my brothers, they always point their fingers to me whenever mom gets angry ? 1…
A: Here I have taken input from the user and then stored it in the variables. Next, I have assigned the…
Q: C++ Programming ::: use Classes and Pointers First Define a class set, which represents set of…
A: A set class is used in below code to perform set operations. While creating the set duplication is…
Q: a. Write a C++ statement that declares secretList to be a vector object to store integers. (Do not…
A: a) vector<int> secretList;
Q: Define a function named get_max_value_and_key (a_dict) function that takes a dictionary object as a…
A: The code and output is given below in python for the above given question:
Q: 1. Write a readEmployee function that takes a pointer to an employee struct and fills in the…
A: Program Details Functions used reademployee It used to read the details of the employee by taking…
Q: Exercise 39.4 Calculate Loan Write a JSF page that lets the user enter loan amount, interest rate,…
A: a JSF page that lets the user enter loan amount, interest rate, and number of years, as shown in…
Q: Operating Systems Assignment 3: Linux System Calls – Shared Memory Write two C++ programs…
A: The /proc virtual file system:Linux uses the /proc file system to collect information from kernel…
Q: 1. Write a readEmployee function that takes a pointer to an employee struct and fills in the…
A: We need to debug and make the code run.
Q: )(i) Create a City structure that will have the following members: name (string type), population…
A: #include <stdio.h>struct City{ char name[100]; int population; float…
Q: 1 3#include #include #include 4 #include #include using namespace std; 7 const int MAXRESULTS ▪…
A: Programming:: Code :: #include<iostream> #include<fstream> #include<istream>…
Q: 1. Write a statement that defines a string constant called Terminal that has the value…
A: Given:
Q: PART 4: How To Remove Redundant Rules ? 13. Sometimes it is desirable to remove the rules that are…
A: How to remove redundant rules by example [1] {A,B,D} -> {C} [2] {A,B} -> {C} [3] Whatever…
Q: Use iterators to print each element of v separted by spaces. #include #include using namespace…
A: Code #include <iostream>#include <vector> using namespace std; int main(){…
Q: Q3: Write a C++ program with a class named search, the class has three member functions, one to full…
A: Task : Write a C++ program with class search having mentioned 3 methods . C++ program :-…
C ++ questions.
1) Fill in the blanks.
a) STL
b) A ______ data member contains information belonging to the class.
2) Fix bugs and potential flaws in this code.
#include<iostream>
int main() {
coordinates.push_back(34);
coordinates.push_back(768);
coordinates.push_back(516);
coordinates.push_back(834);
for(auto it = coordinates.begin(); it != coordinates.end(); it++)
if(*it == 768)
coordinates.erase(it);
for(auto& coordinate : coordinates)
cout << coordinate << ", ";
cout << '\n';
return 0;
}
3) Being able to point to a derived class object with a base class pointer is a result of the ISA relationship. True or False?
Step by step
Solved in 2 steps
- IN C++ NOTE: do not use classes or pointers for Lab 6 - Part B. You are only to use struct data to build your inventory database. Write a program that simulates inventory bins in a warehouse. Each bin holds a number of the same type of parts. The program should use a structure that keeps the following data: Description of the part kept in the bin Number of parts in the bin The program should have an array of 10 bins, initialized with the following data: ------------------------------------------------------- Part Description Number of parts in the bin -------------------------------------------------------- Valve 10 Bearing 5 Bushing 15 Coupling 21 Flange 7 Gear 5 Gear Housing 5 Vacuum Gripper 25 Cable 18 Rod 12…1- Define a struct type that contains a person’s name consisting of a first name and a second name, plus the person’s phone number. Use this struct in a program that will allow one or more names and corresponding numbers to be entered and will store the entries in an array of structures. The program should allow a second name to be entered and output all the numbers corresponding to the name, and optionally output all the names with their corresponding numbers. *'Keep the program as simple as possible using the basic logic of struct the following images attached are just for some reference of what simple basic logic means in my words & also supposed to be applied when solving **single pointers & 2d arrays can be usedTranslator Using as a basis the program that allows to deal cards from a deck to a player's hand, add functionality that allows to update the deck of cards. Updating the deck of cards involves moving the cards from the deck to the beginning of the vector as the player requests a new card. At each deal, the cards in the deck must be printed to make the code in c language. The following functions must be implemented additionally: updateDeck. - This function receives two arguments: a vector with the deck of cards to update and the current size of the deck of cards. It will move the cards in the deck to the beginning of the vector. printVector - This function will receive two parameters: a vector and its dimension. The function will print the vector, and will print the values (the vector) of the initial hand, the updated deck, and the final hand. to make the code in c language Expected output :
- 10.15 LAB: Plant information (vector) C++ Given a base Plant class and a derived Flower class, complete main() to create a vector called myGarden. The vector should be able to store objects that belong to the Plant class or the Flower class. Create a function called PrintVector(), that uses the PrintInfo() functions defined in the respective classes and prints each element in myGarden. The program should read plants or flowers from input (ending with -1), adding each Plant or Flower to the myGarden vector, and output each element in myGarden using the PrintInfo() function. Ex. If the input is: plant Spirea 10 flower Hydrangea 30 false lilac flower Rose 6 false white plant Mint 4 -1 the output is: Plant Information: Plant name: Spirea Cost: 10 Plant Information: Plant name: Hydrengea Cost: 30 Annual: false Color of flowers: lilac Plant Information: Plant name: Rose Cost: 6 Annual: false Color of flowers: white Plant Information: Plant name: Mint…C++ Please Write a program that utilizes a struct data structure and a vector of that structure type. 1. Create an Account struct that includes the following data members: string fName (first name), string IName (last name), string email. 2. Create a vector of type Account called "Accounts". [vector<VectorDataType>vectorName] 3. Create two Accounts acct1 and acct2. Use user-input the get data for the accounts. 4. Add both Accounts to the accounts vector. 5. Use a loop to print every Account in the vector. Struct_Practice.cpp #include <iostream>#include <string>#include <vector>using namespace std; int main(){ struct Account{ string fName; /* ADD CODE HERE */ } Account acct1; Account acct2; vector<Account> accounts; /* ADD CODE HERE */ count << endl; // bank line for (int i=0 ; i< accounts.size();++i){ /* ADD CODE HERE */ } }// end main()OOP using C++ please give me full answer thanks : A designer in 3D graphics company wants to design a matrix as a two-dimensional array. The size of 2D array could be the last two digit of arid number. Initially he creates a class matrix that provides the member function to check that no array index is out of bounds. Make the member data in the matrix class a 10-by-10 array. A constructor should allow the programmer to specify the actual dimensions of the matrix (provided they’re less than 10 by 10). The member functions that access data in the matrix will now need two index numbers: one for each dimension of the array. Here’s what a fragment of a main() program that operates on such a class might look like: If my Arid Number is 20-Arid-254 then: // in case of zero consider next digit matrix m1(5, 4); // define a matrix object int temp = 12345; // define an int value m1.putel(7, 4, temp); // insert value of temp into matrix at 7,4 temp = m1.getel(7, 4); // obtain value from…
- In C++Using the code provided belowDo the Following: Modify the Insert Tool Function to ask the user if they want to expand the tool holder to accommodate additional tools Add the code to the insert tool function to increase the capacity of the toolbox (Dynamic Array) USE THE FOLLOWING CODE and MODIFY IT: #define _SECURE_SCL_DEPRECATE 0 #include <iostream> #include <string> #include <cstdlib> using namespace std; class GChar { public: static const int DEFAULT_CAPACITY = 5; //constructor GChar(string name = "john", int capacity = DEFAULT_CAPACITY); //copy constructor GChar(const GChar& source); //Overload Assignment GChar& operator=(const GChar& source); //Destructor ~GChar(); //Insert a New Tool void insert(const std::string& toolName); private: //data members string name; int capacity; int used; string* toolHolder; }; //constructor GChar::GChar(string n, int cap) { name = n; capacity = cap; used = 0; toolHolder = new…(Card Shuffling and Dealing) Create a program to shuffle and deal a deck of cards. Theprogram should consist of class Card, class DeckOfCards and a driver program. Class Card shouldprovide:a) Data members face and suit of type int.b) A constructor that receives two ints representing the face and suit and uses them to initialize the data members.c) Two static arrays of strings representing the faces and suits.d) A toString function that returns the Card as a string in the form “face of suit.” Youcan use the + operator to concatenate strings.Class DeckOfCards should contain:a) An array of Cards named deck to store the Cards.b) An integer currentCard representing the next card to deal.c) A default constructor that initializes the Cards in the deck.d) A shuffle function that shuffles the Cards in the deck. The shuffle algorithm shoulditerate through the array of Cards. For each Card, randomly select another Card in thedeck and swap the two Cards.e) A dealCard function that returns the next…Instructions: Turn all instances of classes into pointers. You will also need to combine the player and vector into one vector objects and fix all issues this causes. #ifndef ITEM_H #define ITEM_H class Item { public: Item() {}; enum class Type { sword, armor, shield, numTypes }; Item(Type classification, int bonusValue); Type getClassification() const; int getBonusValue() const; private: Type classification{ Type::numTypes }; int bonusValue{ 0 }; }; std::ostream& operator<< (std::ostream& o, const Item& src); bool operator< (const Item& srcL, const Item& srcR); int& operator+=(int& srcL, const Item& srcR); #endif // !ITEM_H #ifndef MONSTER_H #define MONSTER_H #include "Object.h" class Player; class Monster : public Object { public: Monster() {}; Monster(const Player& player); void update(Player& player, std::vector& monsters) override; int attack() const override; void defend(int damage) override; void print(std::ostream& o)…
- Please just use main.cpp,sequence.cpp and sequence.h. It has provided the sample insert()function. No documentation (commenting) is required for this assignment. This assignment is based on an assignment from "Data Structures and Other Objects Using C++" by Michael Main and Walter Savitch. Use linked lists to implement a Sequence class that stores int values. Specification The specification of the class is below. There are 9 member functions (not counting the big 3) and 2 types to define. The idea behind this class is that there will be an internal iterator, i.e., an iterator that the client cannot access, but that the class itself manages. For example, if we have a Sequence object named s, we would use s.start() to set the iterator to the beginning of the list, and s.advance() to move the iterator to the next node in the list. (I'm making the analogy to iterators as a way to help you understand the point of what we are doing. If trying to think in terms of iterators is confusing,…c++ Here are struct data members: integer for the ID of a student character array for the name. The size of the array is 15 floating-point numbers for the GPA an integer for a student status Write the declaration of the struct, lines of code to dynamically allocate size of the struct defined previously, the user will be asked to enter the size of the array, and a function that receives an array of the struct, the length of the array and the student ID as parameters. It should return the name, GPA and student status if found. Make sure to address if not found.Answer this question properly mut attach ouput screen shot This need to be done in C programminng only Write the function compare that takes two parameters of type void* and returns an integer When pointers to Student structures are passed, it compares their GPA and returns 0 if they are equal, a negative value if the first is smaller, and a positive value if the first is greater.