4g. the output of the following C++ code? #include using namespace std; template class XYZ { public: void putPri(); static T ipub; private: static T ipri; }; template void XYZ::putPri() { cout << ipri++ << endl; } template T XYZ::ipub = 1; template T XYZ::ipri = 1.2; int main() { XYZ a; XYZ b; a.putPri(); cout << a.ipub << endl; b.putPri(); }
Q: What is the output of the following C++ code? #include using namespace std; class BaseClass…
A: Code: #include <iostream> using namespace std; class BaseClass { protected: int…
Q: Write a function named “HasDashDashOnBothEnds” that accepts 2 parameters of the same as command line…
A: #include <iostream>using namespace std; bool HasDashDashOnBothEnds(int count, char**…
Q: Class: Desk Data members: weight (integer) Write all external function definition required to make…
A: #include <iostream>using namespace std;class Desk{ public: int weight;…
Q: The following C++ code consists of an error. What is the cause of the error? class Human{ public:…
A: This is based on the concept of virtual functions in C++
Q: Suppose you define the maxValue function as follows: template<typename T1, typename T2> T1…
A: A template is a feature of C++ that allows us to write one code for different data types. It allows…
Q: Q2\Write a program in OOP C++ to represent the employee class: 1-Giving information about the…
A: Array is a contiguous collection of same data type element. Declaration of array data_type…
Q: Define a generic function called CheckOrder() that checks if four items are in ascending, neither,…
A: Approach: Include necessary header files define a generic method CheckOrder to pass different types…
Q: In c++ Please. Given main(), complete class RandomNumbers (in files RandomNumbers.h and…
A: Het there, I am writing the required solution for the above stated question.
Q: Write a program which has a class called Character having a character data member. Overload the…
A: #include <iostream>#include <iomanip>#include <string> using namespace std; int…
Q: If returned value is even it should display on label otherwise display it on textbox. Built-in…
A: Create a class name Exponents and Write a function power(base , exponent) that takes 2 parameters…
Q: TRICTLY USE TEMPLATE PROVIDED AT END OF QUESTION. FOLLOW WHAT IS GIVEN IN QUESTION…
A: Required: program in c++ and must match output as it is . ------------------------------------…
Q: The following C++ code consists of an error. What is the cause of the error? class Human{ public:…
A: ERROR: cannot convert ‘Teacher*’ to ‘Human*’ in assignment h=&t; | ^~ |…
Q: Q3: Write a program in C++ using OOP to create a class (A), that contain integer number (X), contain…
A: Algorithm: Start Create a class A with x as its member and fact() as a function. Create a class B…
Q: Write a C++ Program using classes, functions (recursive and otherwise), arrays and other C++…
A: Start Program to count vowels and consonants. Find upper letters Find lower letters Calculate the…
Q: Create the C++ Function Template named multiples so that it has three parameters sum, x, and n. The…
A: Here, the program is tested by user inputs and you can directly call the function by giving your…
Q: Create a C++ Function Template named swap so that it has two parameters of the same type. A Template…
A: #include <iostream>using namespace std;//templated function declarationstemplate<class T…
Q: create a generic pet and print information using PrintInfo(). create a Dog pet, use PrintInfo() to…
A: The base class Pet has private data members petName, and petAge. The derived class Dog extends the…
Q: Considered the following code (excution begins in main ) What is the output of the code int i = 1,…
A: Solution: Given,
Q: Q6: Write a program in C++ that contains overloaded functions with name OvOperation(). When the main…
A: C++ code for above : #include<iostream> using namespace std; //overloading functions int…
Q: Computer Science Write in Javascript please and use high order functions liek map or filter or…
A: Introduction: The function is a collection of instructions to perform a particular task. Syntax:…
Q: Write a program which has a class called Character having a character data member. Overload the…
A: Given question has asked to write a program which has a class called Character having a character…
Q: Write a program which has a class called Character having a character data member. Overload the…
A: #include <iostream>#include <iomanip>#include <string> using namespace std; int…
Q: Please write this in JAVA as well as use the Eq.txt file provided. intends to auto generate…
A: def equivalence: def __init__(self, v): self.__check(v) def __check(self, val): foo(self,…
Q: Suppose there is a class called X with two double type attributes. Write a C++ program to create two…
A: The question is based on C++ operator overloading. I have included the code in step 2 . I hope this…
Q: Solution in JS Write a function that inserts a white space between every instance of a lower…
A: Algorithm - Take input from user. Now use the below logic - return…
Q: Write in c++ a Template function body called swap( ) to swap the values of the two values of…
A: A template is used to create generic classes and generic functions for executing any type of data.…
Q: Solution in JS Write a function that inserts a white space between every instance of a lower…
A: In this problem, we need to design the code in the Js programming language. Input - String Output…
Q: Q2: Write a program in C++ using 0OP to create a class (A), that contain the following function: A -…
A: #include <iostream> using namespace std; int main(){ //create aray to store 5 Elements…
Q: Q1: Write a program in C++ using OOP to create a class that have string (S), then create the…
A: #include <iostream> using namespace std; //class String class String {…
Q: A template explicit call for the given template function is: template void display(X x, Y y) cout;…
A: The correct answer is: ( b ) display<int , char> (7,'h');
Q: Suppose function f() is static defined in class C and c is an object of the C class. Can you invoke…
A: Static function: A function that does not depend on a particular phase condition is called a static…
Q: Please use c++ .Turn the plus () function in Question 2 into a template. Create a template…
A: Code: #include <iostream> template<typename T>T plus(T p1,T p2){ //c_str() converts…
Q: Q3: Write a program in C++ using OOP to create a class (A), that contain integer number (x), contain…
A: #include<iostream>#include <string>using namespace std;class A { //creating…
Q: Assuming you have a c-string variable "location" with a size of 30, write a line of code that allows…
A: Note: we are only allowed to solve one question in one post. I am solving the first on here. To get…
Q: Write a C++ program in this new file. In this new file, write code that will do the following:…
A: #include<iostream>#include<cmath>//for sqrtusing namespace std;//defining…
Q: 6: Which of the following is a non-true statement(s)? click all apply A) In C++, friend is not a…
A: Given few statements about the C++ programing language and we need to tell which statement is not…
Q: umber of space at the beginning of the line. (in Haskell) code: joinLine :: Line -> String
A: Modify the function joinLine so that it right align the line to lengthlineLen by adding the…
Q: Hello, I am having trouble with this homework question for my c++ course. Implement a Rational…
A: Task: Implement a Rational Number class with the following specifications. Data members a)…
Q: can someone help me with this in C++ In this program, you must implement I/O operator overloading…
A: We need to update the definition of the Triangle and Square classes to add the declaration of the…
Q: Solution in JS Write a function that inserts a white space between every instance of a lower…
A: In JavaScript string.replace method/function is used to inserts a white space between every instance…
Q: Consider the definition of the following function template:template <class type>type…
A:
Q: Please Solve the Question in C++ as quickly as you can in 40 minutes. And do the same as asked in…
A: Algorithm: Start Create a template class SafeArray with data members size, Array Define a…
Q: Write the output of the following C++ code. Also, write the name of feature of Object Oriented…
A: Here we have written the function Line with different numbers and types of parameters. Then, in the…
Q: t) Write a one-liner JAVA function that takes a string s and an integer i as the parameters and…
A: Write a one-liner JAVA function that takes a string s and an integer i as the parameters and removes…
Q: PLEASE USE JAVA Equivalence Class Software Testing Question: A function foo has k integers…
A: Given The answer is given below
Q: What do the keywords virtual and override do in C++?
A: Function overriding is redefinition of base class work in its inferred class with same mark i.e…
Q: (1) Write a C++ program using the following class details: Class Name: Employee public: - void…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: What will be the output of the following C++ program? #include using namespace std; class A{…
A: Given, Code: #include <iostream> using namespace std; class A{ public: A(){…
Q: In C++, write a function (named "templated_array_copy") that takes two parameters (two arrays of the…
A: void templated_array_copy(int source[2], int destination[3]){ //Find size which is smaller int…
Q: of the following statements are correct regarding the use of templates in C++ progr Template…
A: The template is used in the context of word processing software is refers to a sample document that…
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();
}
Step by step
Solved in 3 steps with 2 images
- What is the output of the following C++ code? #include <iostream> using namespace std; class BaseClass { protected: int i; public: BaseClass(int x) { i = x; } ~BaseClass() { } }; class DerivedClass: public BaseClass { int j; public: DerivedClass(int x, int y): BaseClass(y) { j = x; } ~DerivedClass() { } void show() { cout << i << " " << j << endl; } }; int main() { DerivedClass ob(3, 4); ob.show(); return 0; }programming paradigms Please write the following functions in Haskell. Please also write type declarations for each function, including type classes, wherever necessary. 1. Modify isGodzilla from today's lecture to isNum where the function accepts an integer as an input parameter and outputs True if this integer matches the number in the function. 2. Write a function fibList that uses the fib function from today's lecture. fibList accepts a number n as parameter and outputs a list of the numbers in the Fibonacci series up to n. Note that fibList will use a list comprehension involving fib. 3. Write a function justHighScores that takes the list generated as output of the gradeBook function and returns a list of students who score >= 95. Please use the isHighScorer function from today's lecture in justHighScores. You will also have to implement the gradeBook function discussed in class today. 4. Modify the function lastElement from today's lecture to getSecondLast. The function…This is in c++ The base class Pet has private data members petName, and petAge. The derived class Dog extends the Pet class and includes a private data member for dogBreed. Complete main() to: create a generic pet and print information using PrintInfo(). create a Dog pet, use PrintInfo() to print information, and add a statement to print the dog's breed using the GetBreed() function. main.cpp #include <iostream> #include<string> #include "Dog.h" using namespace std; int main() { string petName, dogName, dogBreed; int petAge, dogAge; Pet myPet; Dog myDog; getline(cin, petName); cin >> petAge; cin.ignore(); getline(cin, dogName); cin >> dogAge; cin.ignore(); getline(cin, dogBreed); // TODO: Create generic pet (using petName, petAge) and then call PrintInfo // TODO: Create dog pet (using dogName, dogAge, dogBreed) and then call PrintInfo // TODO: Use GetBreed(), to output the breed of the dog } Dog.cpp #include "Dog.h" #include…
- write the program in c# Create a class name Exponents and Write a function power(base , exponent) that takes 2 parameters of type ” int” that returns the value of base exponent. Base is nonzero positive integer while exponent is positive integer. Call this power method within function button_click of windows form class that reads integer values for base and exponent from user and performs the calculation written in the power method of Exponents class. If returned value is even it should display on label otherwise display it on textbox. Built-in functions are not allowed to use.(Assume label name lblDisplay and textbox name txtDisplay)What is the output of the following C++ code? #include <iostream> using namespace std; class Base { public: int m; Base(int n=0) : m(n) { cout << "Base" << endl; } }; class Derived: public Base { public: double d; Derived(double de = 0.0) : d(de) { cout << "Derived" << endl; } }; int main() { cout << "Instantiating Base" << endl; Base cBase; cout << "Instantiating Derived" << endl; Derived cDerived; return 0; }Please circle True or False for each of the following statements. C++ Keywords public and private are access specifiers for classes in C++. TRUE FALSE
- CPS506 Lab 6 Haskell: Type classes and custom types Preamble In this lab you'll create a custom type in Haskell and make it an instance of several built-in Haskell type-classes. Getting Started The provided cabal project defines a module called Lab6. This module will define a custom type called DigitalTime. The DigitalTime type will be used to represent time as a 3-tuple of integers. One for hour, minute, and second, respectively. Thus, the type definition should look like this: data DigitalTime = DigitalTime (Int, Int, Int) Next, you will implement several type classes over this type. These type classes and their operations can be found below. Assume that the hour range is 1-12. Do not use 24h time. Type Classes to Implement Show: show DigitalTime (h, m, s) Print the time in the format "<hh:mm:ss>" Eq: (==) (DigitalTime (h1, m1, s1)) (DigitalTime (h2, m2, s2)) Two times are considered equal if they have the same hour, minute, and second values. Ord: (<=) (DigitalTime (h1, ml,…FOR C++, PLASE SEND THE ANSER IN 30 MINUTES. ACCORDING TO CODE BELOW, #include "Vehicle.hh" class Ship: public Vehicle { private: int passenger; public: Ship(); Ship(int, float, float); int getPassenger(); void setPassenger(int); void print(); }; (DEFINE FUNCTIONS CORRESPONDING TO SHIP HEADER CLASS IN PART 2 BELOW) #include "Vehicle.hh" #include "Ship.hh" #include <iostream> using namespace std; // *** DEFINE --VEHICLE-- FUNCTIONS FOR PART 1 *** // *** DEFINE --SHIP-- FUNCTIONS FOR PART 2 *** void reduceSpeed(Ship*, float); void takePassenger(Ship*, int); int main() { return 0; } // reduce the speed of ship given in percentage (0 < percentage < 1). void reduceSpeed(Ship *s, float percentage) { // *** FILL THIS FUNCTION FOR PART 3 *** } // takes the number of passengers to the ship void takePassenger(Ship *s, int pas) { // *** FILL THIS FUNCTION FOR PART 4 *** }This is C++. Please explain in details so I can understand the questions.What is the output of the following C++ program? #include <iostream>#include <string>using namespace std;class baseClass{public:void print() const;baseClass(string s = " ", int a = 0);//Postcondition: str = s; x = a;protected:int x;private:string str;};class derivedClass: public baseClass{public:void print() const;derivedClass(string s = "", int a = 0, int b = 0);//Postcondition: str = s; x = a; y = b;private:int y;};int main(){baseClass baseObject("This is the base class", 2);derivedClass derivedObject("DDDDDD", 3, 7);baseObject.print();derivedObject.print();system("pause");return 0;}void baseClass::print() const{cout << x << " " << str << endl;}baseClass::baseClass(string s, int a){str = s;x = a;}void derivedClass::print() const{cout << "Derived class: " << y << endl;baseClass::print();}derivedClass::derivedClass(string s, int a, int b) :baseClass("Hello…
- QUESTION 15 Python supports the creation of anonymous functions at runtime, using a construct called __________ A. def B. pi C. anonymous D. lambdaIn C++ Language: Suppose I have a class named Person. Here is how I would like to use the class: //Create a person named Dave Smith Person dave("Smith", "Dave", 'R'); //Create a person named Gal Gadot Person gal("Gadot", "Gal", 'G'); //Dave and Gal gets married gal = dave + gal; dave = dave + gal; //print Gal and Dave's new married name cout << gal << endl; cout << dave << endl; This will output the following: Gal Smith-Gadot Dave Smith-Gadot Write the class declaration for Personprogram in c++ and must match output as it is . ------------------------------------ Develop a program to overload binary operators. The class Complex has the following public attributes Data type Variable name int real int imaginary Include default constructor to initialize real and imaginary values to 0Include the following functions in the Complex class and overload the binary operators Member function Function description void getvalue() This function is used to read inputs Complex operator+(const Complex& obj) This function will add the real and imaginary partsand return the complex object of added values Complex operator-(const Complex& obj) This function will subtract the real and imaginary partsand return the complex object of subtracted values void display() This function will display the result value In main() function invoke the operator overloading by creating objects for the Complex class. Below statements should be printed in the…