Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:40:54+00:00 2026-06-10T07:40:54+00:00

Please have a look at the following code. Main.cpp #include <iostream> #include Maximum.h using

  • 0

Please have a look at the following code.

Main.cpp

#include <iostream>
#include "Maximum.h"

using namespace std;

int main()
{

    Maximum max;

    int int1, int2, int3;

    cout << "Input three integers: ";
    cin >> int1 >> int2 >> int3;    
    cout << "The maximum value is: " << max.maximum(int1,int2,int3) << endl;




    double double1, double2, double3;

    cout << "Input three doubles: ";
    cin >> double1 >> double2, double3;    
    cout << "The maximum value is: " << max.maximum(double1, double2, double3) << endl;



    char char1, char2, char3;

    cout << "Input three char values: ";
    cin >> char1 >> char2 >> char3;
    cout << "The maximum value is: " << max.maximum(char1,char2,char3) << endl;

}

Maximum.h

template <class T>

class Maximum
{
    public:
        Maximum();
        T maximum(T value1, T value2, T value3);
};

Maximum.cpp

#include  <iostream>
#include "Maximum.h"

Maximum::Maximum()
{

}

    T Maximum::maximum(T value1, T value2, T value3)
    {
         T maximumValue = value1;

        if(value2>maximumValue)
        {
            maximumValue = value2;
        }

        if(value3>maximumValue)
        {
            maximumValue = value3;
        }


        return maximumValue;
    }

In maximum.cpp, it gives “‘T’ does not name a type” error. Since it is a user defined one, it might not identified it. How to solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:40:55+00:00Added an answer on June 10, 2026 at 7:40 am

    Member functions of class templates are themselves templates, and must be defined as such:

    template <typename T>   // <-- Add this
    Maximum::Maximum()
    {
        // code
    }
    
    template <typename T>   // <-- Add this
    T Maximum::maximum(T value1, T value2, T value3)
    {
        // code
    }
    

    Once you’ve fixed that, you’ll probably get some linker errors, because templates must (usually) be defined in every translation unit that uses them. The fix is to move the definitions into the header file. See this question for full details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have following code for heapsort #include <iostream> using namespace std; void exch(int a[],int
I have the following code: #include <iostream> #include <string> void main() { std::string str;
Please have a look at the following code namespace Funny { class QuesionsAndAnswers {
Please have a look at following code : import java.util.ArrayList; import java.util.List; class Main{
Please have a look at the following code: #include <stdio.h> #include <stdlib.h> typedef struct
Please have a look at the following code Main.Java import java.awt.event.*; import java.awt.*; import
Have a look at the following code: #include<unistd.h> #include<stdlib.h> #include<stdio.h> #include<string.h> #include<sys/types.h> main() {
please have a look at the following code import java.util.ArrayList; import java.util.List; public class
Please have a look at the following code: $(#saveButton).click(function(){ $this = $(#tableData).find(input:checked).parent().parent(); tea =
Please have a look at the following code package Euler; import java.util.ArrayList; import java.util.List;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.