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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:16:09+00:00 2026-06-03T00:16:09+00:00

I have a class Graph whose copy constructor is declared in Graph.h like this:

  • 0

I have a class Graph whose copy constructor is declared in Graph.h like this:

template<typename Object,typename Weight>              
Graph<Object,Weight>::Graph(Graph<Object,Weight>& G)

Elsewhere, I try to use it:

Graph<double,double> G = make_graph("dense.g");

…but it gives me the following error:

time_trialsALIST.cpp:37: error: no matching function for call to `Graph::Graph(Graph)'
Graph.h:142: note: candidates are: Graph::Graph(Graph&) [with Object = double, Weight = double]

I don’t understand why this would happen; the make_graph function just returns a Graph:

Graph<double,double>  make_graph(string filename){...} 

Do I need an ‘&’ somewhere?

  • 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-03T00:16:12+00:00Added an answer on June 3, 2026 at 12:16 am

    Read the answer here. In other words, you’re missing a const, not an &. Make it:

    template<typename Object,typename Weight>              
    Graph<Object,Weight>::Graph(const Graph<Object,Weight>& G)
    

    You can’t bind a temporary to a non-const reference.

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

Sidebar

Related Questions

I have Vertex template in vertex.h. From my graph.h: 20 template<class edgeDecor, class vertexDecor,
I have a class named Graph, in this class I have a member named
I have a class that does an implementation of a graph (template class) in
I have an Object called Graph. I have list of Vertices in Graph class.
I have class Vertex{ Graph _graph; float x; float y; string key; //and some
I have a class Graph with two lists types namely nodes and edges I
I have class A, which exposes an event. an object of class B subscribed
how to represent a graph with list data structure i have three class (Graph,
I have a graph object, that I need to serialize. Nomatter which members i
I have a function (assign) in a class (graph) in a header file. The

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.