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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:16:22+00:00 2026-05-26T10:16:22+00:00

I believe this question has been asked before. I tried looking for it but

  • 0

I believe this question has been asked before. I tried looking for it but still can’t figure out the problem. I’d greatly appreciate any help I can get here. Thanks

I get the following error. I get an idea that I am not initializing the Vertex once I call the constructor of the Edge. But I can’t seem to figure out how.

10369.cpp: In constructor ‘Edge::Edge(Vertex, Vertex)’:
10369.cpp:34: error: no matching function for call to ‘Vertex::Vertex()’
10369.cpp:30: note: candidates are: Vertex::Vertex(int, int)
10369.cpp:6: note:                 Vertex::Vertex(const Vertex&)
10369.cpp:34: error: no matching function for call to ‘Vertex::Vertex()’
10369.cpp:30: note: candidates are: Vertex::Vertex(int, int)
10369.cpp:6: note:                 Vertex::Vertex(const Vertex&)

    #include <iostream>
    #include <math.h>
    using namespace std;

//Vertex in a graph, with x & y coordinates 
    class Vertex{
        int x , y;
        public:
            Vertex(int, int);
            ~Vertex();

            int GetX() {return x;};
            int GetY() {return y;};

    }; 

// Edge of a graph calculated from two vertices
    class Edge{
        Vertex U , V;
        float edge_weight;
            public:
                Edge(Vertex , Vertex);
                ~Edge();

                 float GetEdgeWeight() { return edge_weight; }


    };

    Vertex::Vertex(int _x , int _y){
        x = _x;
        y = _y;
    } 

// The edge weight is calculated using the pythagoras
    Edge::Edge(Vertex _U , Vertex _V){
        U = _U;
        V = _V; 
        int x = V.GetY() - U.GetY();
        int y = V.GetX() - U.GetX();
        edge_weight = sqrt(pow(x,2) + pow(y,2));

    }   
    int main (int argc , char *argv[]){

        Vertex V1(0,1) ; 
        Vertex V2(0,3);
        Edge E(V1, V2);
        float x = E.GetEdgeWeight();
        cout << x << endl;


        return 0;
    }
  • 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-26T10:16:23+00:00Added an answer on May 26, 2026 at 10:16 am

    Always use constructor initialiser lists to initialise data members — your Vertex has no default constructor, this is one of the cases where you absolutely must use an init list.

    Edge::Edge(Vertex U, Vertex V) : U(U), V(V), edge_weight(...) { }
    Vertex::Vertex(int x, int y) : x(x), y(y) { }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can see that this question has been asked several times, but none of
I see that this question has been asked before but the context around the
I believe that this question has been asked in a few different forms, but
I'm almost sure this question has been asked before, but for the love of
I believe this questions has been asked in some or the other way but
I believe this question has been asked a lot of times, and I have
You're probably thinking this has been asked a million times before but I think
I realise this question has been asking before, but I've yet to find an
I am sure this has been asked before, but I have yet to find
Yes, I know this question has been asked 1000 times before... here is 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.