Posts by Maniero • 444,682 points
6,921 posts
-
4
votes1
answer48
viewsA: Unable to initialize a generic object with inheritance
You need to learn about variance. A compound object can only have variance according to inheritance if it is made explicit that this is allowed, otherwise it is not automatic. And there is another…
-
3
votes1
answer59
viewsA: Dynamic memory allocation gives error while accessing
The first problem is that you are relocating the object and playing on the variable r who dies there. It seems he wants to play in po even to reflect on array in the calling function. But then we…
-
7
votes1
answer102
viewsA: What is the difference between a global variable and a global variable Static?
Global is a somewhat ambiguous term. Their lifespan is global, in fact. But their visibility is quite different. The traditionally declared non-local variable has really global visibility. But when…
-
4
votes2
answers68
viewsA: Automatic null value check versus types like "Option<T>"?
I’ll start by saying that Java has and it was the language that drove the most idea of the indiscriminate use of null. Now she has another option, just like other languages have it now officially or…
-
1
votes1
answer57
viewsA: Letter to lowercase conversion gives a numerical result
Besides the precise disorganized code means you want a letter and not a number because according to the documentation that’s what the function tolower() results by default. #include <iostream>…
-
5
votes3
answers81
viewsA: Is it possible to use functions in an arbitrary order in C++?
C and C++ are languages that have chosen to be one step, that is, they analyze what they find in the order and evaluate what to do with that in the order that came. Modern languages tend to avoid…
-
4
votes1
answer135
viewsA: What is UML? What is it for?
UML or Unified Modeling Language, as the name says is a modeling language, that is, it should describe how a domain model should be. It was standardized by the Object Management Group (OMG) to be…
-
5
votes1
answer135
viewsQ: What is UML? What is it for?
A conceptual issue. What is UML? What good is? Is it really useful? Therefore, we must learn? Is widely adopted? What defects of this language? Is linked with object orientation?…
-
6
votes1
answer124
viewsA: How abstract are pointers in C?
We can say that conceptually pointers are abstract. In fact almost everything is abstract, concrete even only excited electrons (people rave when I speak like this :D) circulating by static…
-
2
votes2
answers55
viewsA: What is the Bufferedstream of C#?
This class exists basically to create a technique of double buffer when it is needed in some scenario, or for use in conjunction with some stream that is not bufferized and you need this. If you use…
-
6
votes2
answers11641
viewsA: What is Reflection. Why is it useful?
I decided to answer because the answer currently accepts and with many votes is essentially wrong. It’s not that everything is wrong, and I understand the reason for the error, a lot of people get…
-
4
votes2
answers77
viewsA: When to use constexpr in C++?
I would start by reading the documentation which is considered almost official by everyone. Without mastering the documentation do not consider that you understand the mechanism, especially in C++…
-
4
votes2
answers191
viewsA: What are the main differences between prototype-oriented programming and class-oriented programming?
Well, the question doesn’t focus on the specific implementation, as it is that of Javascript, so I won’t talk so much about the points that JS chose so, even though it is the most popular…
-
0
votes1
answer50
viewsA: Not falling in the if according to the number being higher or lower
You’re saving text instead of number, then you do math operations and comparisons with that information which goes wrong, so you have to convert to number before you do this. A lot of things could…
-
3
votes1
answer48
viewsA: What is the point of using Option as a type in the argument of a function?
If you don’t like it and don’t need it, don’t use it. You almost always don’t need it. But if you use it, you have to pay the price the engine charges. Everything is tradeoff in computing. When you…
-
2
votes3
answers91
viewsA: Make a program that receives 5 numbers and show the following output:. C++
A shame to mix C with C++, but come on. The last element cannot have the plus sign, so it has to be treated as an exception and not within the loop, because it has no reason to pay inefficiency with…
-
1
votes1
answer30
viewsA: How does the Dbcontext startup work in the Entity Framework Core?
From a general point of view this is wrong, but pay attention because now I will talk about what is common to do, then I explain that the DbContext is special. Every class that implements…
-
4
votes2
answers100
viewsA: What does "ad-hoc" mean in the context of computing?
The term means that something exists for a specific purpose, which has a characteristic only for the object of which it deals there. I believe, but I’m not sure ad hoc polymorphism indicates that it…
terminologyanswered Maniero 444,682 -
1
votes1
answer45
viewsA: Printing vector memory garbage
There’s a conceptual problem in storage. And I don’t even know if I can do it right because the statement is bad. Each vector needs to store only the numbers that are pertinent to them. Then each…
-
2
votes1
answer46
viewsA: How to scan the matrix using only one for?
In fact, the internal tie makes no sense, it travels through a dimension but only wants one element, so use that element instead of going through all of them. In practice you only need index 1 and…
-
2
votes1
answer54
viewsA: Python bitwise operator output
Do: print(~1) print(~0) Same thing, right? After all True vale 1 and False vale 0. Therefore he applied the complement operation on these numbers when using the boolean literals. The complement…
-
1
votes1
answer78
viewsA: I want to know how to show, for the user, Yes or No instead of True or False, respectively
You have to process it conditionally and present what you want. The result of a boolean was not meant to be presented except in very specific circumstances. lm = input ('Digite uma letra ')…
-
2
votes1
answer40
viewsA: Why is a vector in C passed as a parameter by reference?
All data types are passed as arguments by value to the parameter. The vector is given that it holds a pointer, this is the value of it. The pointer points to another object in another memory…
-
1
votes0
answers43
viewsQ: What is a Promise?
Why does it exist? How does it work and how should it be used in the simplest way? Any specific care? When is abuse to adopt this mechanism? Exists only in Javascript?
-
1
votes1
answer46
viewsA: Why does the list error Object has in the 'checks' attribute occur?
You are receiving a list of checks and with the for takes each of them, so there’s nothing called cheques within each cheque, has for example, valor. But there is another problem that will make it…
-
2
votes2
answers77
viewsA: Memory allocation with malloc()
First: this account uses a wrong concept to see the allocated space, nothing prevents to allocate an object at a huge distance from another, so measuring the distance between them will not give,…
-
1
votes1
answer89
viewsA: You are giving variable not defined within an if
I did not carefully analyze the statement so if the logic of the code is wrong I did not fix it. I only pressed to execute what is intended by looking only at the code solving the reported problem.…
-
4
votes1
answer128
viewsA: Convert lower case letter to upper case without using "toupper()"
There are several errors there, not to mention the bad organization and nomenclature and the use of things that are not necessary. Already in the main code if you do not reserve the space for the…
-
4
votes1
answer60
viewsA: Private encapsulation in inheritance
First attribute is something you were taught wrong: What is the difference between attribute and field in the classes?. What you’re calling encapsulation is actually information Hiding, begin by…
-
3
votes1
answer62
viewsA: Code error for letter detection
There are several mistakes, some more critical than others. Come on. The function must return an integer data type as defined by the problem and not a type that does not return value. The variable x…
-
4
votes1
answer104
viewsA: Why does my running function only return "0"?
Failed to compare with the letter a and walk on the index in each letter. The a in an element of array, to be valid the next element should be s, and the following must be a. The question code is…
-
4
votes1
answer56
viewsA: I have trouble printing the output of a string array
The biggest problem is that space is not reserved for the string, only to the matrix, then corrupts all memory. I put a constant to facilitate since probably want to change the size of classes and…
-
5
votes1
answer64
viewsA: What is the access modifier of an explicit implementation?
Explicit interface implementation is always public (see language specification). There is no reason not to be, and decided that since it is the only way, it would not allow to say in the code that…
-
4
votes1
answer79
viewsA: Is it possible to force a method to be extended in Java?
The public is not the one that can be extended with more freedom, there is no difference in this aspect regarding the visibility of the method. All methods are extensible by default in Java, so you…
-
3
votes1
answer66
viewsA: Stack overflow exception being generated in the instance method "Equals()"
The instance method is calling the wrong method by the overload resolution rules. This method is receiving an object of type Object and is passing to a method that waits Object, so it is not the…
-
2
votes1
answer104
views -
2
votes1
answer28
viewsA: Array does not return value using a static method function
To print a array it is necessary to format it, one of the ways is the print_r(): class Dtb { public static $funcionarios = ['M','G','N','I'] ; public static $atividades = 'Sistemas'; public static…
-
3
votes1
answer36
viewsA: Problems using "using" to access static methods
You must statically import the class and not the method: using static Crypt.CaesarCipher; public class Program { public static void Main() => Decode("", 0); } namespace Crypt { public static…
-
0
votes1
answer44
viewsA: Why isn’t to_s being overwritten?
The to_s must return a value of type string that makes sense to that object and whoever receives this value does whatever you want with it, for example the puts will print this text. When you have…
-
6
votes2
answers88
viewsA: A Setter method can receive a getter + value as a parameter?
It’s okay to do that. But there’s one question that the use of this type of pattern creates: the code gets a little less DRY and has two ways to access the field, directly and indirectly. It is not…
-
5
votes1
answer255
viewsA: Calculation of the sum of the elements of a matrix
There are syntax errors there, for example calling the function with declaration syntax and trying to pass the type as argument, it does not exist, it includes passing the size of the array, you…
-
2
votes1
answer94
viewsA: A program that sums up n numbers where the odd numbers will be disregarded, where it works as it should
You are using the variable n which was declared and not initialized, so it may have junk in memory and that junk value that was already there was used for sum. It makes no sense to use the value…
-
6
votes1
answer62
viewsA: Difference of {} and = in a declaration
This is called Uniform Initialization Syntax or Uniform Boot Syntax which is the preferred way to initialize variables in C++ since version 11. It is true that the initialization of primitive simple…
-
3
votes1
answer102
viewsA: Memory allocation for string array with malloc()
The main problem is that you are initiating the array 0 then will only corrupt the memory by putting things where nothing has been reserved. Sending it to boot after you know how big it should be.…
-
4
votes1
answer60
viewsA: Asymptotic analysis of the best and worst case
I always say that finding the real complexity is not that simple. Looking over we can say easy that it is O(n) being n the size of string s which will be known when typing the text, ie, is linear…
-
6
votes1
answer79
viewsA: What is the difference between the function "malloc()" and a created variable?
To create an object it is not necessary to call malloc(), even because it is made to allocate dynamic memory, only that. It allocates memory and returns an address where there was allocation.…
-
4
votes3
answers123
viewsA: Problem when denying receipt of a certain value
You are not knowing how to use logical operators. The and is when you want all the conditions together to be true, and the or is when you want at least one of them to be true. Then it is sufficient…
-
7
votes3
answers229
viewsA: Convert the string "5.541.00" to int in C#
The right shape is using the style of value and the culture it is to be able to identify the pattern. And of course, check if it worked before using, because it might fail (TryParse()), I will not…
-
1
votes1
answer41
viewsA: Take only values after the comma in a double
The truncate() is a way to take the whole part , the round() is another, but for this case the best would be toInt(). Always use the documentation to learn more about the API available for the…
-
4
votes3
answers95
viewsA: Pass Enum value per method parameter
Why don’t you use the method ordinal() that all enum has? Stay like this: class Program { public static void main (String[] args) { Status status = Status.Cancelada;…