
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
4g. the output of the following C++ code?
#include <iostream>
using namespace std;
template <class T>
class XYZ
{
public:
void putPri();
static T ipub;
private:
static T ipri;
};
template <class T>
void XYZ<T>::putPri()
{
cout << ipri++ << endl;
}
template <class T> T XYZ<T>::ipub = 1;
template <class T> T XYZ<T>::ipri = 1.2;
int main()
{
XYZ<int> a;
XYZ<float> b;
a.putPri();
cout << a.ipub << endl;
b.putPri();
}
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write the PrintItem() function for the base class. Sample output for below program:Last name: Smith First and last name: Bill Jones Hint: Use the keyword virtual to make PrintItem() a virtual function. #include <iostream>#include <string>#include <vector>using namespace std; class BaseItem {public: void SetLastName(string providedName) { lastName = providedName; }; // FIXME: Define PrintItem() member function /* Your solution goes here */ protected: string lastName;}; class DerivedItem : public BaseItem {public: void SetFirstName(string providedName) { firstName = providedName; }; void PrintItem() const override { cout << "First and last name: "; cout << firstName << " " << lastName << endl; }; private: string firstName;}; int main() { BaseItem* baseItemPtr = nullptr; DerivedItem* derivedItemPtr = nullptr; vector<BaseItem*> itemList; unsigned int i; baseItemPtr = new…arrow_forwardIn Kotlin, Use this revised Employee class: data class Employee(val id: Int, val name: String, val wage: Double, val hours: Double) Create a list of Employees Write a function fireEmployee, which takes a list of Employees and an id number and returns a list that consists of all the original employees wihtout any that have that id. a) use filter in the function b) revise the function to take a function or a lambda to determine who gets fired. For example, you should be able to write a lambda and pass it to the function to result in everyone named "Xavier" getting fired. c) revise the function to use a tail-recursive helper function instead of filterarrow_forwardWrite the PrintItem() function for the base class. Sample output for below program: Last name: Smith First and last name: Bill Jones Hint: Use the keyword const to make PrintItem() a virtual function. Partially completed code (C++): #include <iostream>#include <string>#include <vector>using namespace std; class BaseItem {public:void SetLastName(string providedName) {lastName = providedName;}; // FIXME: Define PrintItem() member function /* Your solution goes here */ protected:string lastName;}; class DerivedItem : public BaseItem {public:void SetFirstName(string providedName) {firstName = providedName;}; void PrintItem() const override {cout << "First and last name: ";cout << firstName << " " << lastName << endl;}; private:string firstName;}; int main() {BaseItem* baseItemPtr = nullptr;DerivedItem* derivedItemPtr = nullptr;vector<BaseItem*> itemList;unsigned int i; baseItemPtr = new BaseItem();baseItemPtr->SetLastName("Smith");…arrow_forward
- #include <iostream> using namespace std; class A { private: int x; public: A(int _x) { x = _x; } int get() { return x; } }; class B { static A a; public: static int get() { return a.get(); } }; int main(void) { B b; cout << b.get(); return 0; } Excecute and provide the screenshot.arrow_forwardHELP ME CODE COMPLEX.CC IN istream& operator>>(istream &lhs,Complex& rhs)PLEASE complex.cc #include <iostream>#include "complex.h"using namespace std; //Class definition file for Complex //YOU: Fill in all of these functions//There are stubs (fake functions) in there now so that it will compile//The stubs should be removed and replaced with your own c Dr // defaultComplex::Complex() {real = 0;imagine = 0;} Complex::Complex(int new_real, Imaginary new_imagine) {real = new_real;imagine= new_imagine; }// + operator overloadComplex Complex::operator+(const Complex &rhs) const {Complex num;num.real = real + rhs.real;num.imagine = imagine + rhs.imagine;return num;}// - operator overloadComplex Complex::operator-(const Complex &rhs) const {Complex num;num.real = real - rhs.real;num.imagine = imagine - rhs.imagine;return num;}// * operator overloadComplex Complex::operator*(const Complex &rhs) const {Complex num;num.real = real * rhs.real;num.imagine =…arrow_forward#include <iostream> #include <string> #include <cstdlib> using namespace std; template<class T> T func(T a) { cout<<a; return a; } template<class U> void func(U a) { cout<<a; } int main(int argc, char const *argv[]) { int a = 5; int b = func(a); return 0; } Give output for this code.arrow_forward
- write a complete member function in class set defined by you in this code to count number of elements in intersection between 2 sets : the code is ::: using C++ Programming #include <iostream> using namespace std; class Set{int n,set[10]; public: void create (){cout<<"Enter Number Of Elements:";cin>>n;int val;cout<<"Enter Elements in set:"<<endl;cin>>set[0];for (int i=1;i<n;i++){cin>>val;for (int j=0;j<i;j++){if (set[j]==val){i--;break;}else{set[i]=val;}}}cout<<"Set Created"<<endl;} void display (){for (int i=0;i<n;i++){cout<<set[i]<<" ";}cout<<endl;} void setUnion (Set *s2){Set s3;int x=0,y=0,z=0;while (x<n && y<s2->n){if (set[x]<(*s2).set[y]){s3.set[z]=set[x];x++;z++;}else if (set[x]==(*s2).set[y]){s3.set[z]=set[x];x++;y++;z++;}else{s3.set[z]=(*s2).set[y];y++;z++;}}while (x<n){s3.set[z]=set[x];x++;z++;}while (y<(*s2).n){s3.set[z]=(*s2).set[y];y++;z++;}s3.n=z;s3.display ();}…arrow_forwardCan help with this in c++The base class is given Base: class Base { int a;double b;public:Base (int _a, double _b) : a(1), b(2.5) {}Base (int _a, double _b) :a(_a), b (_b) {}double calct () {return 1.5*a+2*b;}string toString(){return "a="+to_string(a) + "b=" + to_string(b);}};Define a class Derived, successor to Base, with an additional field d of type double. For Derived, write constructors, write a new implementation of the calc () method to add to the sum and field d with coefficient 3 and the toString () method, which returns the text description of an object of class Derived.Create objects of class Derived with the written constructors and call the two variants of the methods calc () and toString () (of the class Derived and its base class Base)arrow_forwardC programming fill in the following code #include "graph.h" #include <stdio.h>#include <stdlib.h> /* initialise an empty graph *//* return pointer to initialised graph */Graph *init_graph(void){} /* release memory for graph */void free_graph(Graph *graph){} /* initialise a vertex *//* return pointer to initialised vertex */Vertex *init_vertex(int id){} /* release memory for initialised vertex */void free_vertex(Vertex *vertex){} /* initialise an edge. *//* return pointer to initialised edge. */Edge *init_edge(void){} /* release memory for initialised edge. */void free_edge(Edge *edge){} /* remove all edges from vertex with id from to vertex with id to from graph. */void remove_edge(Graph *graph, int from, int to){} /* remove all edges from vertex with specified id. */void remove_edges(Graph *graph, int id){} /* output all vertices and edges in graph. *//* each vertex in the graphs should be printed on a new line *//* each vertex should be printed in the following format:…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education