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

  • SEARCH
  • Home
  • 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 8753441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:25:28+00:00 2026-06-13T13:25:28+00:00

I am trying to write a template class for Insertion Sort algorithm. But I

  • 0

I am trying to write a template class for Insertion Sort algorithm. But I am encountering the error “error C4430: missing type specifier – int assumed. Note: C++ does not support default-int”. But I am not sure why this error is coming.

insertion_sort.h file as follows:

     #pragma once
     #include <iostream>
     template <typename T,int SIZE>
     class insertion_sort
     {
           T data[SIZE];
      public:
       insertion_sort(void);
       void set_data();
       void sort_data();
       void show_data();
      ~insertion_sort(void);
     };

insertion_sort.cpp file as follows:

#include <iostream>
#include "insertion_sort.h"
using namespace std;


template <typename T,int SIZE>
insertion_sort<T,SIZE>::insertion_sort(void)
{
    typedef typename int i;
for(i=0;i<SIZE;i++)
   data[i]=NULL;
}
template <typename T,int SIZE>
insertion_sort<T,SIZE>::set_data(void)
{
    typedef typename int i;
    cout<<"ENTER THE DATA"<<endl;
    for(i=0;i<SIZE;i++)
       cin>>data[i];
}
template <typename T,int SIZE>
insertion_sort<T,SIZE>::sort_data()
{
    typedef typename int i,j;
    T key;
    for(i=1;i<SIZE;i++)
    {
          j=i-1;
          key=data[j]
          while(data[j-i]>key)
          {
             data[j]=data[j-1];
             j--;
           };
           data[j+1]=key;
     }
}
 template <typename T,int SIZE>
insertion_sort<T,SIZE>::show_data()
{
typedef typename int i;
for(i=0;i<SIZE;i++)
    cout<<data[i]<<"\t";
}
template <typename T,int SIZE>
insertion_sort<T,SIZE>::~insertion_sort(void)
{
}

main.cpp file is as follows:

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

using namespace std;

int main()
{
    insertion_sort<char,5> S;
    S.set_data();
    S.sort_data();
    S.show_data();
    return 0;
}

When I build the code I am getting following error:

c:\documents and settings\devil_den\my documents\visual studio 2008\projects\sorting_algorithms\sorting_algorithms\insertion_sort.cpp(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

c:\documents and settings\devil_den\my documents\visual studio 2008\projects\sorting_algorithms\sorting_algorithms\insertion_sort.cpp(34) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

c:\documents and settings\devil_den\my documents\visual studio 2008\projects\sorting_algorithms\sorting_algorithms\insertion_sort.cpp(41) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

main.cpp
Generating Code...
Build log was saved at "file://c:\Documents and Settings\devil_den\My Documents\Visual Studio 2008\Projects\Sorting_Algorithms\Sorting_Algorithms\Debug\BuildLog.htm"
Sorting_Algorithms - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  • 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-13T13:25:29+00:00Added an answer on June 13, 2026 at 1:25 pm

    The definitions of set_data(), sort_data() and show_data() are missing their return types. All are declared to have return type of void so just add to the definitions:

    template <typename T,int SIZE>
    void insertion_sort<T,SIZE>::set_data(void)
    {
        // snip ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a template class in C++ and getting this strange
noob here still experimenting with templates. Trying to write a message processing class template
I am trying to write a generic one-size-fits-most repository pattern template class for an
I keep getting the following error when trying to write a template function: main.cpp|17|error:
I am trying to write a template like this. template <char c,typename Options, basic_string<class,class,class>
I'm trying to write a template that takes a template to a non-type parameter
I'm trying to write a derived class of STL set<> and a link error
I am trying to write graph class as a template class. As answered in
I'm trying to write some dimension-independent code for a template class in c++, using
I am trying to write a class template that provides a comparison operator between

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.