конструктор

Class constructor. I don't understand. C++

Good time of day! I study the book of Datelov, 5th edition. And now either the translator has gone too far, or I can't under ... f another SecondClass class (for example)? Why are they mentioned about them? What does this paragraph want me to do tell me?

How to create a constructor in the descendant with parameters that do not match the parameters of the base constructor

There is a constructor in the base class public Kons(int a, string b){} You need to make a constructor in the heir public ... c):base(a,b){} Writes that the non-static field b requires a reference to the object. You can't make b static. What to do?

Java Constructors

Hello everyone! There is a basic constructor: public abstract class JS { public Context context; public JS(Context ... there is no constructor with such parameters... Please tell me why? In other object languages, this works, but not in Java..

How are enumerations implemented in Java?

Recently, I have been asking questions about the implementation of some data types that are actually part of the language its ... for self-development, as I really like to understand what is "under the engine". Thank you all so much for your help! :)

Why add super () to the constructor of a child class if the compiler does it automatically?

Why add the super() call to the child class constructor if the compiler does it automatically? I mean, in any case, the constructor of the parent class will be executed first, and only then the child class, so why write it manually?

Put the labels through the PC browser in the map designer to display on the phone in Yandex maps

In general-I spread leaflets on the front doors, I was faced with the fact that it is not convenient to enter a new address e ... more convenient - I put labels in the PC browser and exported it to the phone. Please tell me the option decisions. Thank you

Constructing a vector in C++11 breaks the old code

When porting code from C++98 to C++11, I ran into a problem: #include <iostream> #include <vector> struct A { ... std::vector<A>(5); } This code should output 122222, and outputs 11111. Why is this happening, and how to fix it?

Constructor logic in inheritance

Why does the C++ logic allow a derived class to use a constructor WITHOUT base class parameters, BUT does NOT allow using a c ... // объект производного класса } When creating the constructor of the derived class, a different parameter was used. WHY?

Constructor with parameters and by default

class AB { private: int a; int b; public: AB() { a = 10; b = 10; } }; clas ... diately set values inside the constructor and that's it. I don't know, maybe my question is stupid. Don't judge. I'm a newbie

Do I need a copy constructor here?

In general, there is such a task. Create a Student class with the fields last name, number of grades, grades (dynamic array ... second such task.I've been thinking about it for a long time, but it only gets in the way of my decision.Can anyone tell me?

"explicit" for copy and move constructors

Is it necessary (and if so, in which cases) to specify the copy and move constructors as explicit? I saw this in the code and didn't quite understand it. Where is the unnecessary implicit conversion that explicit helps us avoid?

C++ Implicitly calls an extra constructor. Classes as fields of another class

There is a simple program in c++. There are three classes, one containing the private fields of the other 2. When calling the ... ER, TEMPERATURE }; class Sensor { string unitOfMeasured; int maximum; int minimum; float value; ..... }

Is it an error to redefine a constructor without parent:: construct () inside?

Is it correct to completely override the parent constructor in PHP without parent::__construct ()? Noticed that PhpStorm swears at "missing parent constructor call".

this when declaring a Java constructor

There are two options for declaring a constructor: public class MyClass() { int a, b, c; MyClass (int a, int b, ... isual, but which form of writing is preferable and more professional? And are there any pitfalls when using this in this way?

Initializing an array using the Java constructor

You need to implement bubble sorting for the array. In this case, the array is initialized with: an empty constructor that ... } When creating an object, the starter constructor is not called, the array is not initialized. Then NullPointerException.

explicit - practical application

I understand the principle of working with the keyword explicit constructors. What is the practical application? If we want ... es of "fencing", then when: A a('x'); we will still get the result above. There will still be an unnecessary (us) conversion.

Initializing a vector in the constructor

class A { public: A(size_t size):vector(size, default_value){} private: std::vector<int> vector; const int default_ ... Why is the vector initialized with a random value? Does the constant not have time to become -1 yet? How to do it right then?

Is there any way to simplify class initialization in Python?

I have a class constructor of something like this: class A: def __init__(self, a1, a2, ..., an): self.a1 = a1 ... ask one more question: What should I do if some arguments have a default value, and some arguments have a default value? no?

Replacing constructors with a static generation method

I read that you can replace the constructor with a static generation method. I have two private fields in my class private ... ables. the compiler swears at the same signature. You can tell us how this can be solved using the static generation method.

C++: how to set the dimension of a two-dimensional vector in the class constructor

Class Matrix { int dimension; vector<vector<int>> matrix; public: Matrix(int dimensio ... id it doesn't work matrix.reserve(dimension); for (int i = 0; i < dimension; ++i) { matrix[i].reserve(dimension); }