C++ structure

Asked 1 years ago, Updated 1 years ago, 74 views

structure Edge {int to, cost;
Edge(){}
Edge(int to, int cost):to(to), cost(cost){};

What does this mean?
Is Edge(){} a function?

c++ c++11

2022-09-29 22:56

1 Answers

Is Edge(){} a function

Constructor. In C++, the member function declaration "No return type, function name with type name" is constructor. () is argumentless, and {} is the absence of actual processing in constructor.(The next line is a constructor with arguments.)

You may not be familiar with it if it comes from a proper(?) C++ code, but if you look at the books and sites that explain C++ from the basics, you will find many of them in this way.

If you could show us how well you know about C++, we might be able to add a little more.


2022-09-29 22:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.