Answered step by step
Verified Expert Solution
Question
1 Approved Answer
swapperclass.cpp #include using namespace std; class my_class { int x; int y; public: my_class(int a, int b); void swapper(); void printem(); }; my_class::my_class(int a, int
swapperclass.cpp
#includeusing namespace std; class my_class { int x; int y; public: my_class(int a, int b); void swapper(); void printem(); }; my_class::my_class(int a, int b) { x = a; y = b; } void my_class::swapper() { int TempVal = x; x = y; y = TempVal; } void my_class::printem(){ cout Part 2--Class Templates Download the following file. The file: swapperclass.cpp swapperclass. cpp contains a class and implementation for swapping two integer values Your primary task for this exercise is: 1. Create a class template which will swap two values of any type and print them. Steps include: o Implement your code in three files: swapper. cpp, swapper. h, main.cpp. The purpose for this is to see the problem that occurs when using Visual Studio with templates. See Section 6 (below). o Your class should be capable of initializing two data members o Your class should have a function for swapping the two data members. o Your class should also have a function for printing the two data members. o Try different types so that your program can handle int char double . Your output may look similar to the output from
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started