Sponsored Content
Full Discussion: code output(not believable)
Top Forums Programming code output(not believable) Post 302238849 by SamRoj on Monday 22nd of September 2008 07:13:00 AM
Old 09-22-2008
code output(not believable)

Code:
#include<iostream> 
using namespace std; 

class base 
{ 
public: 
int bval; 
base(){ bval=0;} 
}; 

class deri:public base 
{ 
public: 
int dval; 
deri(){ dval=1;} 
}; 

void SomeFunc(base *arr,int size) 
{ 
for(int i=0; i<size; i++,arr++) 
cout<<arr->bval; 
cout<<endl; 
} 

int main() 
{ 
base BaseArr[5]; 
SomeFunc(BaseArr,5); 
deri DeriArr[5]; 
SomeFunc(DeriArr,5); 
}

could you pls. explain why the code output is like below:
00000
01010

Last edited by jim mcnamara; 09-22-2008 at 11:35 AM.. Reason: add code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Better to Use Return Code or wc -l Output?

Hey All, Quick question... I'm writing a short script to check if a continuous port is running on a server. I'm using "ps -ef | grep -v grep | grep processName" and I was wondering if it was better/more reliable to just check the return code from the command or if its better to pipe to... (12 Replies)
Discussion started by: mrm5102
12 Replies

2. UNIX for Dummies Questions & Answers

Remove area code using from awk output

I am back again with one more question, so I have a phonebook file with names, phone#s for example: smith, joe 123-456-7890 using awk I want to display all entries with a specific area code. here 's what i have tried so far: awk '$2~/^123/ {print}' phonebook I can't figure... (1 Reply)
Discussion started by: Nirav4
1 Replies

3. Shell Programming and Scripting

Remove error code in output

Hi, i have the below code that will compare the value from 2 variables: ./wlst.sh JMSmon.py > out.dat w=`sed -e 's/\(.*!\)\(.*\)\(, Queue.*$\)/\2/' out.dat | awk '/'$1'/{n=0;{print $n}}'|head -n 1` if then x=`sed -e 's/\(.*!\)\(.*\)\(, Queue.*$\)/\2/' out.dat | awk '/'$1'/{n=2;next}n{print... (2 Replies)
Discussion started by: scripter123
2 Replies

4. Programming

Strange characters in FORTRAN code output

Hi guys, After compiling a .f90 code and executing it, i get strange characters in the output file like : ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ Are these windows characters? how can i get rid of this? Much appreciated. Paul (1 Reply)
Discussion started by: Paul Moghadam
1 Replies

5. Shell Programming and Scripting

Perl code to output data

Hello, I have a much larger data set like the attached example. Is there a code that will output the data to look like? Thank you. hg19_pseudoYale60_PGOHUM00000245279 chr1:242220709-242223574 hg19_pseudoYale60_PGOHUM00000243857 chr1:120820-133580 hg19_pseudoYale60_PGOHUM00000243858 ... (2 Replies)
Discussion started by: cmccabe
2 Replies

6. Shell Programming and Scripting

Same sed code prints(p) correct, but writtes(w) wrong output

Dear all, I am using sed as an alternative to grep in order to get a specific line from each of multiple files located in the same directory. I am using sed because it prints the lines in the correct order (unlike grep). When I write sed code that prints out the output I get it correct, but... (1 Reply)
Discussion started by: JaNaJaNa
1 Replies

7. UNIX for Beginners Questions & Answers

Check output of command before outputing and keep exit code

so i have scripts that are piped and then run through one of the following mechanisms: cat myscript.sh | sh cat myscript.pl | perl what i want to do is, after either of the above commands are run, if the output from the command contains a certain string, i want it to avoid printing... (3 Replies)
Discussion started by: SkySmart
3 Replies

8. UNIX for Beginners Questions & Answers

When I run the code yesterday I am getting output,when I run same code today I am getting error?

If run the below code today its creating all directory and getting output files,I f run same code tomorrow I am getting error. can any one give suggestion to sortout this error. OSError: no such file or directory : '062518'My code looks like this import paramiko import sys import os ... (8 Replies)
Discussion started by: haribabu2229
8 Replies

9. What is on Your Mind?

Should we use CODE Tags for terminal input and output?

I've always used code tags for code but not for showing terminal input and output. I noticed a mod edited one of my threads and now I'm confused as to proper protocol. Mike (5 Replies)
Discussion started by: Michael Stora
5 Replies
branch(2rheolef)						    rheolef-6.1 						  branch(2rheolef)

NAME
branch - a parameter-dependent sequence of field DESCRIPTION
Stores a field sequence together with its associated parameter value: a branch variable represents a pair (t,uh(t)) for a specific value of the parameter t. Applications concern time-dependent problems and continuation methods. This class is convenient for file inputs/outputs and building graphical animations. EXAMPLES
Coming soon... LIMITATIONS
This class is under development. The branch class store pointers on field class without reference counting. Thus, branch automatic variables cannot be returned by func- tions. branch variable are limited to local variables. IMPLEMENTATION
template <class T, class M = rheo_default_memory_model> class branch_basic : public std::vector<std::pair<std::string,field_basic<T,M> > > { public : // typedefs: typedef std::vector<std::pair<std::string,field_basic<T,M> > > base; typedef typename base::size_type size_type; // allocators: branch_basic (); branch_basic (const std::string& parameter_name, const std::string& u0); branch_basic (const std::string& parameter_name, const std::string& u0, const std::string& u1); ~branch_basic(); // accessors: const T& parameter () const; const std::string& parameter_name () const; size_type n_value () const; size_type n_field () const; // modifiers: void set_parameter (const T& value); void set_range (const std::pair<T,T>& u_range); // input/output: // get/set current value __obranch<T,M> operator() (const T& t, const field_basic<T,M>& u0); __obranch<T,M> operator() (const T& t, const field_basic<T,M>& u0, const field_basic<T,M>& u1); __iobranch<T,M> operator() (T& t, field_basic<T,M>& u0); __iobranch<T,M> operator() (T& t, field_basic<T,M>& u0, field_basic<T,M>& u1); __branch_header<T,M> header (); __const_branch_header<T,M> header () const; __const_branch_finalize<T,M> finalize () const; rheolef-6.1 rheolef-6.1 branch(2rheolef)
All times are GMT -4. The time now is 04:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy