constructor tag

35 questions


1 answers
131 views
0
Can I call a constructor from another constructor?

Is it possible for a constructor to call a constructor within the same class? Not the lower class.What do I do?

2 years ago

1 answers
146 views
0
Calling a constructor within a constructor

When I developed C#, I used it like the code below, but I wonder how I do it in C++.I wrote this() to call out the class name, but it says noWhy? class Test {public: Test() { //DoSomething } Test(int...

2 years ago

2 answers
148 views
0
What does the explicit keyword in C++ do?

I'm going around the internetgoI saw the C++ code below What does this explicit do for you?class String {public: explicit String (int n); //allocate n bytes String(const char *p); // initialize sobjec...


1 answers
89 views
0
Why do we use colons (:) in constructors?

I saw a code like this#include <iostream>class Foo {public: int bar; Foo(int num): bar(num) {};};int main(void) { std::cout << Foo(42).bar << std::endl; return 0;}What is written her...


1 answers
176 views
0
When is a virtual constructor used?

When is the virtual constructor used for C++?Virtual constructors seem to be a really useless feature, but I don't know when. Isn't superclass constructor called automatically when inherited? Why both...

2 years ago

1 answers
76 views
0
C++ Copy Generators Call

#include <iostream>using namespace std;class SoSimple{private: int num;public: SoSimple(int n) : num(n) { cout << New Object : << this << endl; } SoSimple(const SoSimple&...

2 years ago

2 answers
137 views
0
Multiple constructors are required for Java inheritance

I'm a self-taught student in Java. I am studying inheritance and super class nowIf a superclass can have multiple constructors, I would like to ask you how to create a subclass constructor. The code I...


1 answers
154 views
0
c++ Class Problem Questions

The problem embodies the functions, constructors, and destructors of ClassInfo In the main() function, enter (B511001, Kim Cheol-soo, 23), (B611002, Kim Young-hee, 26), and (B411003, Youngsoo Kim, 24)...

2 years ago

1 answers
101 views
0
This is a question about the principle of temporary copying of the member variable in C++ Default Copy Generator

class baseDMA{private: char* label; int rating;public: baseDMA(const char* l=NULL, int r =0); baseDMA(const baseDMA& rs); virtual ~baseDMA(); baseDMA& operator=(const baseDMA& rs); friend ...


1 answers
98 views
0
Please tell me the order in which the results of the generator extinction program example came out

# include <iostream> using namespace std ; class Point { int x, y ; public: Point(int x=0, int y=0) { this->x = x ; this->y = y ; cout << \tPoint ; print() ; cout << con...

2 years ago
- 1 - »

© 2024 OneMinuteCode. All rights reserved.