08-29-2014
You have a big long cout calling multiple things which have side-effects on each other, and the order they are done is ambiguous -- remember this is a compiled, heavily optimized language, not a one-at-a-time string interpreter. Re-imagine your code like this:
myfunction(die1.getnum(), die2.getnum(), die1.roll(), die2.roll());
When written that way, whether roll() gets called before or after getnum() is more obviously ambiguous.
Split it into two cout statements to avoid the side-effects.
It has nothing to do with the const. It just means that calling that function has no side-effects. It doesn't guarantee that all other functions have no side effects however.
Last edited by Corona688; 08-29-2014 at 12:49 PM..
This User Gave Thanks to Corona688 For This Post:
9 More Discussions You Might Find Interesting
1. Programming
I'm having a problem getting this to work..
I got 3 files,
start.C - Where i got my main() function
Menu.C & Menu.h - Where I'm trying to use hash_map
start.C
#include <iostream>
#include "Menu.h"
using namespace std;
int main() { /* test code here */ return 0; }
Menu.h ... (1 Reply)
Discussion started by: J.P
1 Replies
2. Programming
Each thread has a copy of auto variables within a function, but variables
declared as static within a function are common to all threads. To circumvent
this can static variables be placed outside the function. If so, will the
scope of the variable be file only or will it be extern, and will each... (7 Replies)
Discussion started by: sundaresh
7 Replies
3. AIX
What is the scope of AIX as I am starting my career as a fresher in AIX administration?? (4 Replies)
Discussion started by: abhishek27
4 Replies
4. Shell Programming and Scripting
Hi ,
I'm trying to change the variable value in a while loop , however its not working it seems that the problem with subshells while reading the file.
#!/bin/sh
FLAG=0;
cat filename | while read data
do
FLAG=1;
done
echo $FLAG
Should display 1 instead displays 0 (13 Replies)
Discussion started by: dinjo_jo
13 Replies
5. Shell Programming and Scripting
Hi,
I am stuck while developing a shell sub-routine which checks the log file for "success" or "failure". The subroutine reads the log file and checks for key word "success", if found it set the variable (found=1). It returns success or failure based on this variable.
My problem is, I can... (2 Replies)
Discussion started by: cjjoy
2 Replies
6. Shell Programming and Scripting
Hi,
I want to know about the variable scope in shell script.
How can we use the script argument inside the function?
fn () {
echo $1 ## I want this argument should be the main script argument and not the funtion argument.
}
also are there any local,global types in shell script?
if... (3 Replies)
Discussion started by: shellwell
3 Replies
7. High Performance Computing
Hi, I'm trying to define an MPI_datatype for a structure, then do message passing for this created datatype. However, when I tried to broadcast the initialized data from rank 0, I found that part of the received data at other ranks are not correct. Could you please help me take a look at my code... (0 Replies)
Discussion started by: qb13
0 Replies
8. Shell Programming and Scripting
Hello
I am having issues with a script I'm working on developing on a Solaris machine.
The script is intended to find out how many times a particular user (by given userid) has logged into the local system for more than one hour today.
Here is my while loop:
last $user | grep -v 'sshd'... (7 Replies)
Discussion started by: DaveRich
7 Replies
9. Shell Programming and Scripting
Hello,
I met a problem with following code:
#!/usr/bin/perl -w
# test.pl
use strict;
use diagnostics;
use DBI;
my $dbh = DBI->connect(
"DBI:mysql:BibleBook","yifangt","password")
or die("Cannot connect: $DBI::errstr");
my $sql = qq(SELECT * FROM library WHERE isbn =... (2 Replies)
Discussion started by: yifangt
2 Replies
LEARN ABOUT DEBIAN
xcompmgr
xcompmgr(1) General Commands Manual xcompmgr(1)
NAME
xcompmgr - sample X compositing manager
SYNOPSIS
xcompmgr [-d display] [-r radius] [-o opacity] [-l left-offset] [-t top-offset] [-acCfFnsS]
DESCRIPTION
xcompmgr is a sample compositing manager for X servers supporting the XFIXES, DAMAGE, and COMPOSITE extensions. It enables basic eye-candy
effects.
OPTIONS
-d display
Specifies the display to manage.
-r radius
Specifies the blur radius for client-side shadows.
-o opacity
Specifies the opacity for client-side shadows.
-l left-offset
Specifies the left offset for client-side shadows.
-t top-offset
Specifies the top offset for client-side shadows.
-I fade-in-step
Specifies the opacity change between steps while fading in.
-O fade-out-step
Specifies the opacity change between steps while fading out.
-D fade-delta
Specifies the time (in milliseconds) between steps in a fade.
-a Automatic server-side compositing. This instructs the server to use the standard composition rules. Useful for debugging.
-c Client-side compositing with soft shadows and translucency support.
-f When -c is specified, enables a smooth fade effect for transient windows like menus, and for all windows on hide and restore events.
-n Simple client-side compositing.
-s Server-side compositing with hard-edged shadows.
-C When -c is specified, attempts to avoid painting shadows on panels and docks.
-F When -f is specified, also enables the fade effect when windows change their opacity, as with transset(1).
-S Enables synchronous operation. Useful for debugging.
BUGS
Probably. Please report any you find to http://bugs.freedesktop.org/.
AUTHORS
Keith Packard, with contributions from Matthew Allum, Eric Anholt, Dan Doel, Thomas Luebking, Matthew Hawn, Ely Levy, Phil Blundell, and
Carl Worth.
xcompmgr(1)