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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:36:07+00:00 2026-06-05T14:36:07+00:00

I have an AdjacencyList class and I want all graph algorithms to be seperated

  • 0

I have an AdjacencyList class and I want all graph algorithms to be seperated from it. Let’s say all algorithms are functors and derive from GraphAlgorithm abstract base class. How do I make it work?

I am currently thinking,

class AdjacencyList
{
    // ...
    friend class GraphAlgorithm;
    // ...
};

But is it allowing GraphAlgorithm’s sub-classes to access private members of AdjacencyList?

Any other approaches are welcome.

  • 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-05T14:36:09+00:00Added an answer on June 5, 2026 at 2:36 pm

    But is it allowing GraphAlgorithm’s sub-classes to access private members of AdjacencyList?

    No, it does not. Friendship is not transitive.

    Regardless, whenever you need a friend declaration, you should regard it as a code smell and re-think your design.

    I would rather have getters in the AdjacencyList and so a GraphAlgorithm can operate on the members it has access to from the methods of AdjacencyList.

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

Sidebar

Related Questions

I have Adjacency list mode structure like that and i want to count all
I have a class like this: template<class T> class AdjacencyList { public: void delete_node(const
In python I have a graph as adjacency list presentation. and a distance from
I want to remove a vertex w with his neighbours from an graph G.
I have an adjacency_list graph defined as follows: struct VertexProperties{ std::string name; ... };
I have an adjacency list of objects (rows loaded from SQL database with the
have written this little class, which generates a UUID every time an object of
I want to define a generic class in c++ that allow to execute my
I have a defined a simple template class. In this class I define a
I have the adjacency list of a large graph stored in a table. v1

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.