can someone help me create and initialize a pointer to function of DisplayInfo for a template specific data type (double)
here is DisplayInfo prototype
template <typename ObjType>
void DisplayInfo(const ObjType &object)
// do comment if any problem arises
// code
#include <iostream>
using namespace std;
template <typename ObjType>
void DisplayInfo(const CPersonInfo<ObjType> &object)
{
cout<<"Name: "<<object.GetName()<<endl;
cout<<"Age: "<<object.GetAge()<<endl;
cout<<"Weight: "<<object.GetWeight()<<endl;
cout<<"Height: "<<object.GetHeight()<<endl;
}
int main(int argc, char const *argv[])
{
void (*ptr)(const CPersonInfo<double> &);
ptr = DisplayInfo;
return 0;
}
can someone help me create and initialize a pointer to function of DisplayInfo for a template...
Can someone explain these terms to me in C++? Thanks 1. Templates: 2. Function: 3. Template Instantiation: 4. Overload operators: 5. This pointer: 6. Binary operator: 7. Friend function: 8. Overloading post increment operator: 9. Type: 10. Class Templates:
Given the following code: #ifndef TREE_H #define TREE_H #include <iostream> #include "TreeNode.h" template< typename NODETYPE > class Tree { public: Tree() : rootPtr( nullptr ) {} void insertNode( const NODETYPE &value ) { insertNodeHelper( &rootPtr, value ); } void preOrderTraversal() const { preOrderHelper( rootPtr ); } void inOrderTraversal() const { inOrderHelper( rootPtr ); } private: TreeNode< NODETYPE > *rootPtr; void insertNodeHelper( TreeNode< NODETYPE > **ptr, const NODETYPE &value ) { if ( *ptr == nullptr ) * ptr = new...
-Create a function output() in C that takes the pointer to the array and its size and prints the arrays' contests. (malloc format) (function prototype : void output(int *arrayPtr, int size); -Create a function check() in C that takes the pointer to the array and a number and checks if the number is in the array. If the number is in the array, returns the index of the element of the array holding the number. Otherwise, returns -1.
What is the specific answer for 1. and 2. Thanks! Add a new method, find, to class SinglyLinkedList (defined here) that takes as input a “data” value and returns a pointer to a node. If the input data is present in the linked list, the returned pointer should point to that node; if not, the returned pointer is nullptr. Write the (single line) method declaration/specification. Write the method definition/implementation. Test by running the main() function below and capture the console...
Please use the linked approach implement the BST ADT,
implement all the functions in the BSTree.cpp. Add the ouput of the
implementation.
use recursive functions to traverse the tree - read the
implementation notes on using helper functions.
Please use C++ programming
//////////////////////////////////////////////////////////////
#include "BSTree.h"
template <typename DataType, class KeyType>
BSTree<DataType, KeyType>::BSTreeNode::BSTreeNode ( const
DataType &nodeDataItem, BSTreeNode *leftPtr, BSTreeNode
*rightPtr )
{
}
template < typename DataType, class KeyType >
BSTree<DataType, KeyType>::BSTree ()
{
root = 0;
}
template...
Create a template function printResult which prints a value of type T void printResult(T val); C++ Write a program to create two Mathematic type (template below) objects a(10, 5) and b(3.4, 5.5) which prints using the template function printResult the result of a.addition(), a.subtraction(), a.multiplciation(), a.division() b.addition(), b.subtraction(), b.multiplication(), b.division() (Template) template <typename T> class Mathematics{ private: T val1, val2; public: Mathematics(T v1, T v2) { val1 = v1; val2 = v2; } T addition() { return val1 + val2;...
Can
you help me to create this program, please?
Prompt the user for the user for a number of degrees in Fahrenheit as an int. That number should be passed to a function named ffocREFO. This function will do the necessary calculation to convert the passed temperature to degrees Celsius as a double. The function MUST have a void return type and have the following prototype: void ffccREF(double& celsius, int Faren); In your main, display both the entered temperature and...
Binary Tree Template Write your own version of a class template that will create a binary tree that can hold values of any data type. Demonstrate the class with a driver program. Place your binary tree template in it's own header file, Btree.h. Include methods for the following: inserting new values into the tree removing nodes from the tree searching the tree returning the number of nodes in the tree displaying the contents of the tree using preorder traversal Your...
Review the Stack implementation with Vector, and
implement/answer the following methods.
Stack One of the principles of good programming is to reuse existing code whenever practical. If you can reuse existing code, you don't need to spend the time to rewrite it. Code used previously has also been debugged, and will likely contain fewer errors. One of the easiest ways to create a container is to leverage an existing data type to build a new abstraction. In this lesson we...
C++
1. The copy constructor is used for one the following scenarios: I. Initialize one object from another of the same type. II. Copy an object to pass it as argument to a function. III. Copy an object to return it from a function. Read the following program and answer questions (20 points) #include <iostream> using namespace std; class Line public: int getLength( void); Line( int len // simple constructor Line( const Line &obj) 1/ copy constructor Line (); //...