|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
Since we have no idea what you installed it is difficult to give an answer. You should check the output from the install to see what happened. You can also use the list sub-command to check what has been installed.
|
|
|
|
|
Further to what Richard has said, you can check which files were installed with dpgk -L <package> Unless you've installed a doc or lib package, you've almost certainly got an executable somewhere.
Keep Calm and Carry On
|
|
|
|
|
My doubt is about the basic theory of "or logical operator". Especifically, logical OR returns true only if either one operand is true.
For instance, in this OR expression (x<O || x> 8) using x=5 when I evalute the 2 operands, I interpret it as both of them are false.
But I have an example that does not fit wiht it rule. On the contrary the expression works as range between 0 and 8, both included. Following the code:
#include <stdio.h>
int main(void)
{
int x ;
do
{
printf("Imput a figure between 1 y 8: ");
scanf("%i", &x);
}
while ( x < 1 || x > 8 );
{
printf("Your imput was ::: %d ",x);
printf("\n");
}
printf("\n");
}
I really appreciate any helpo in order to clarify my doubt
In advance, thank you very much. Otto
|
|
|
|
|
You might be confused by a pair of spurious braces
#include <stdio.h>
int main(void)
{
int x ;
do
{
printf("Imput a figure between 1 y 8: ");
scanf("%i", &x);
}
while ( x < 1 || x > 8 );
{
printf("Your imput was ::: %d ",x);
printf("\n");
}
printf("\n");
}
What the program does is to repeat the scanf statement until x is between 1 and 8.
Antoher way to explain it: the loop repeats until the condition is false. !( (x<1) || (x>8) ) is equivalent to !(x<1) && !(x>8) (see De Morgan's laws[^]), or (x>=1) && (x<=8) .
Mircea
|
|
|
|
|
Hi Mrice, very interesting your contibutions. I am just beginning and exploring basics of programming. And understand it is like a puzzle for me. Also Morgan's law is good reference. Something abstract, but for sure I am going to review it deeply.
I really apreciate all your time you took for answer me-
Otto Medina
|
|
|
|
|
How does logical OR work?
"Logical or," not to be confused with "bitwise or," is a short-circuiting operator that evaluates to an integer, either 0 or 1.
Because it is short-circuiting, the second operand will not be evaluated if the first operand determines the result. In the case of OR, that means if the first operand is non-zero. (In the case of logical AND, the evaluation short-circuits if the first operand IS zero, since that determines the result.)
Finally, if the second operand is evaluated, there is guaranteed to be a sequence point before evaluation of the second operand. This means it is "safe" to use things that require sequence points, like the operators that have side-effects (++, --).
Consider this code:
int first(int x) {
puts("first");
return x;
}
int second(int x) {
puts("second");
return x;
}
void test(int x) {
if (first(x) || second(x)) {
puts("logical or returns true");
}
else {
puts("logical or returns false");
}
}
If I call test(0) what will happen?
The test function will call first(0) which will print its message and return 0. Because 0 is "false", the result of the logical or is not determined, so the second operand is evaluated. This calls second(0) which will print its message and return 0. Since both sides evaluate to 0 (false), the OR also evaluates to 0 and the if fails, so the else clause is invoked.
The output is something like:
second
logical or returns false
Now, if I call test(1) what happens?
The first operand is first(1) which prints its message and returns 1. 1 is truthy, so the result of the logical OR is determined and there is no need to evaluate the second operand. The call to second is skipped and the if succeeds and prints its message. The output looks like:
logical or returns true
How does the looping code work?
The code in question is:
{
printf("Imput a figure between 1 y 8: ");
scanf("%i", &x);
}
while ( x < 1 || x > 8 );
A do/while statement first invokes the body, then evaluates the condition. If the condition is true, the body is repeated and the condition re-evaluated until such time as the condition becomes untrue.
This statement is designed for tasks like input validation, where the body is used to collect input, then the condition is used to determine if the input is invalid. Because the body is always executed, it forces the input to be collected at least once, as compared with the "while (condition) {body}" loop form, where a premature condition could prevent the body from executing.
So in the code example, we have a prompt for input, then a scanf statement for collecting input (Note: see here: http://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.html). This "prompt / input" body is surrounded by a do/while loop so the input will be collected at least once before the input variables are checked.
The input validation is to repeat the input while (x < 1 || x > 8) . This means that either of those conditions is NOT acceptable. If x is less than 1, repeat the prompt and input. Or, if x is greater than 8, repeat the prompt and input. Only when the logical or fails and both conditions are false will the input loop be stopped and the input considered acceptable.
This means that the valid range for the input is [1, 8]. Anything eise just gets the prompt again.
|
|
|
|
|
Hi Aghast
Thanks for your time.
I have red your answer at least about 10 times, and I feel that I am close to understand the logic of the determined range in this do while expression.
I really appreciate all your pacient in this excellent explanation.
Otto
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
Try dimensions.height() or dimensions.width()
Mircea
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
Member 14968771 wrote: I think I need to read-up on "friend" - that semms to be the real OOP ticket
On the contrary: that might take you into a non-OOP design.
The idea of using public member functions is to make your code independent of internal implementation details of other classes. In your case, a class representing a rectangle might keep a corner of the rectangle and its dimensions. Another one might keep two opposite corners or some other combination. If you try to access private members of the class your code will need to change when or if the implementation of the rectangle changes. If you stick to using only public interface, the internal details of the rectangle class may change but your code will remain the same.
You cannot "buy" your way inside a class using a friend declaration. Just like in real life, the friendship is not a symmetrical relation. If you put a friend QRect declaration inside your class that doesn't give you any special access rights. It gives access rights to QRect to your class but obviously QRect is not going to use those rights. You would need to modify the QRect header file to insert a friend declaration mentioning your class. This is very intrusive and basically defeats the purpose of OOP design.
I cannot make an OOP design course here, but there are some pretty good references available.
Mircea
|
|
|
|
|
Member 14968771 wrote: I guess height and width are QRect public variables derived from "private" data. No, they are public methods that give you read-only access to private members.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
One of the steps I invariably do, when debugging, is comment-out private blocks ... essentially rendering all statements public. Now that I get typing ... and that's just for starters.
Without the essential error code (warning?) accompanying a successful compilation/link/running blank form ... there's little more time expendable for me, especially if you're already running debugger and just don't care to get descriptive enough with words and include a code.
So, I'll just cut to the chase.
|
|
|
|
|
Hacking it.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
|
But true.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
Member 14968771 wrote: In the mean time I'll looking at usage of "friend".
Don't waste your time, since it will not make any difference. You cannot declare your class to be a friend of some other class in the hope of accessing its private variables. If that was possible then the millions of applications would be open to hacking. Do what I suggested above and make use of the information provided in the documentation: that is what it is there for..
|
|
|
|
|
It was serious, actually. If you the designer of the class made a member private then you have two ways to access it: the publicly exposed interface (for instance the get/set methods) or a dirty hack on its bare representation in memory. Typically you cannot use friend because you are not the designer of the class.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Private members are only accessible via public functions.
Try int start_X = QPoint.SetX(dimentions.x2);
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
This looks suspicious to me:
&MainWindow::Run_DDD_OPTION(testWidget)
It looks like you're trying to create a pointer to whatever Run_DDD_OPTION returns. However, you also say
Run_DDD_OPTION(testWidget); which either means that it returns void or you didn't care what it returned. My guess is the former, which would explain all the error messages. If it returns void , you can't take its address, and there is no lvalue (=a memory address).
EDIT: If you want to pass the function Run_DDD_OPTION as an argument to addAction, just write
addAction(tr("&Device Discovery Dialog(modified Bluetooth scanner)"),
this,
MainWindow::Run_DDD_OPTION
); You may need the & in front of the function name--I haven't done this in a long time, so I have to look it up. --It looks like it's optional. If it doesn't work without it, try it with it.
modified 15-Jun-21 17:48pm.
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|