Need help with programming c++ The goal of this project is to enable students to
ID: 3603725 • Letter: N
Question
Need help with programming c++
The goal of this project is to enable students to practice programming templates. You will writea template C++ class called "GenericRecord" and a main) function that uses the class. The project details are provided below 1. INTRODUCTION You just noticed that you write many programs that process data records that have the following attributes: Identifier Description Value You decide that you will write a template class called GenericRecord to be used to instantiate objects of this format 2. DATA STRUCTURES 2.1 Template class The template class will take one parameter as follows: template class GenericRecord The class should have a data member in the private section of the class whose type is the template parameter.Explanation / Answer
#include <iostream>
using namespace std;
template <class T>
class Test
{
// Data memnbers of test
public:
Test()
{
// Initializstion of data memnbers
cout << "General template object ";
}
// Other methods of Test
};
template <>
class Test <int>
{
public:
Test()
{
// Initializstion of data memnbers
cout << "Specialized template object ";
}
};
int main()
{
Test<int> a;
Test<char> b;
Test<float> c;
return 0;
}
#include <iostream>
using namespace std;
template <class T>
class Test
{
// Data memnbers of test
public:
Test()
{
// Initializstion of data memnbers
cout << "General template object ";
}
// Other methods of Test
};
template <>
class Test <int>
{
public:
Test()
{
// Initializstion of data memnbers
cout << "Specialized template object ";
}
};
int main()
{
Test<int> a;
Test<char> b;
Test<float> c;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.