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 8278171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:55:04+00:00 2026-06-08T08:55:04+00:00

In a project I’m working on, I have a fairly large templated class that

  • 0

In a project I’m working on, I have a fairly large templated class that I’ve implemented like this:

I have my header file

// MyBigClass.h
#ifndef MYBIGCLASS_H
#define MYBIGCLASS_H

template <typename T>
class MyBigClass {
   /* -- snip -- */
};

#include "MyBigClass.cpp"
#include "MyBigClass_iterator.cpp"
#include "MyBigClass_complicatedFunctionality_1.cpp"
#include "MyBigClass_complicatedFunctionality_2.cpp"

#endif

And then all of my implementation files look basically like this:

// MyBigClass_foobar.cpp

template <typename T>
void MyBigClass<T>::member_1(){
   /* -- snip -- */
}

template <typename T>
int MyBigClass<T>::member_2(int foo, T & bar){
   /* -- snip -- */
}

// etc, etc

In main.cpp, I just include MyBigClass.h, and everything works and compiles fine. The reason I’ve split the implementation into many files is because I prefer working on three or four 200-400 line files, versus one 1200 line file. The files themselves are fairly logically organized, containing for example only the implementation of a nested class, or a group of interrelated member functions.

My question is, is this something that is done? I got a strange reaction when I showed this to someone the other day, so I wanted to know if this is a bad practice, or if there is a better, more usual way to accomplish something like this.

  • 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-08T08:55:05+00:00Added an answer on June 8, 2026 at 8:55 am

    It’s convention to generally not include cpp files (there are limited and exotic cases when this is done), that’s probably the reason you got the weird looks.

    Usually this separation is done by moving the implementation to an .impl or even a .h file instead of a cpp file.

    And no, there’s nothing wrong with separating the implementation of templates and including the file in the header.

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

Sidebar

Related Questions

Project Structure I have a silverlight project SLProj, that references a silverlight class library
My project has viewmodels labeled like this: public class locViewModel { [Required] public string
The project that I am working on (Node.js) implies lots of operations with the
Project I'm working on uses jQuery. I have a series of Ajax calls being
Project file here if you want to download: http://files.me.com/knyck2/918odc So I am working on
Project is C#. So I have a bunch of multithreaded code that is designed
project type is MVC2. Let say that i have page1. after success it write
Project: ASP.NET 3.5 with C# I have this much :- A table which used
Project Background: I am writing a map tile overlay class for java that can
(This project is all written in JS) So, I have a table called paid_offers

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.