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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:31:22+00:00 2026-05-14T22:31:22+00:00

I know how to do an opaque object in C++ as following: // my_class.hpp

  • 0

I know how to do an opaque object in C++ as following:

// my_class.hpp
class opaque_object;
class my_class {
    my_class();
    ~my_class();
    opaque_object *m_opaque_object;
};

// my_class.cpp
#include <my_class.hpp>
class opaque_object {
    // ...
};
my_class::my_class() { m_opaque_object = new opaque_object(); }
my_class::~my_class() {delete m_opaque_object; }

Now how to do it when the opaque object is an existing class template in a different namespace without including the header file of this one. The following code is not good, it is just here to illustrate my problem.

// my_class.hpp
class third::party::library::opaque_object<
    third::party::library::templated_class>;

class my_class {
    my_class();
    ~my_class();
    third::party::library::opaque_object<
        third::party::library::templated_class> *m_opaque_object;
};

// my_class.cpp
#include <my_class.hpp>
#include <third/party/library/opaque_object.hpp>
#include <third/party/library/template_class.hpp>

typedef third::party::library::opaque_object<
    third::party::library::templated_class> opaque_object;

my_class::my_class() { m_opaque_object = new opaque_object(); }
my_class::~my_class() {delete m_opaque_object; }

The actual class of my source code is even more templated than this example (4 arguments of template with some of them which are themselves templated class).

Since my_class.hpp is used quite everywhere in my project, the general compilation take a lot of time (5sec juste to include my_class.hpp for each cpp file) so I would like to avoid including opaque_object.hpp, template_class.hpp … in my_class.hpp.

How can this be done ? Any comment, or idea to do it are welcome.
Thanks in advance for your time.

  • 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-05-14T22:31:23+00:00Added an answer on May 14, 2026 at 10:31 pm

    Need to declare each templated class as well as each class needed as for template (template argument) with the right namespace.

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

Sidebar

Related Questions

I know what a key is, I know what opaque is in other contexts
I am new to Rails, and I am finding it extremely opaque. I have
I would like to know if I can make an image opaque if set
May I know the usage and logic behind the opaque pointer concept in C?
I have a JavaScript class that displays a partially-opaque div over top of the
Know of an OCAML/CAML IDE? Especially one that runs on Linux?
Know of any good libraries for this? I did some searches and didn't come
Know this might be rather basic, but I been trying to figure out how
Know if it's possible to access the iPhone compass in Safari using JavaScript? I
I know in certain circumstances, such as long running processes, it is important to

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.