Objects don't work that way. They don't transfer between themselves magically, you have to give them some way to do so. There's a lot of ways.
Code:
class MyClass
{
public:
MyClass() { value=4; }
getValue() { return(value); }
int value;
};
class OtherClass
{
public:
void use_result_obj(const MyClass &my)
{
cout << "value=" << my.value << "\n";
}
void use_result_int(int value)
{
cout << "value=" << value << "\n";
}
};
int main(void)
{
MyClass a;
OtherClass b;
// generate result in a.value
a.some_function();
// one way to transfer
b.use_result_obj(a);
// another way
b.use_result_int(a.value);
// yet another way
b.use_result_int(a.getValue());
return(0);
}
You might want to review some basic C++.
Last edited by Corona688; 02-04-2010 at 03:20 PM..
Reason: typos in code
Hi All,
I have been trying to set variable environment for the JAVA_HOME but it doesn' work. The path set is as follows
setenv JAVA_HOME "/usr/local/jdk1.3"
setenv PATH $JAVA_HOME/bin
setenv CLASSPATH ${JAVA_HOME}/lib/tools.jar:{JAVA_HOME}/lib/dt.jar
can anyone suggest Me where am I and... (2 Replies)
I have some function
function()
{
fileNamelist=( `find Uploads -name "somePattern" | tr '\n' ' '` )
}
but "local fileNamelist" makes it variable.
How do I declare fileNameList as a local array in BASH? (1 Reply)
Hi all,
It might seem like a very trivial question but I am new to shell scripting so excuse for that.
I have an existing script in CSH. I need to create a function in the script which takes some parameters and returns a result. Can someone please let me know the syntax for function... (4 Replies)
Hello,
how can I define a global variables in KLD?
I would like to define some variables in my KLD and then would like to use them from other KLD.
Thanx (1 Reply)
Hi guys. i have the following script:
1 #!/bin/bash
2 linkcount=$(grep "/portal" tickets | wc -l)
3 grep "/portal" tickets > links
4 for i in $(seq 1 $linkcount); do
5 echo "BLYAT"
6 let link$i=$(sed -n "$i"p links)
7 echo $
8 done
the problem is, that "let" can`t... (1 Reply)
Hi,
In shell script, I have a value and i like to move that value to a particular position in a file.
For example, if i have 20000909 then i like to move that to the 15 to 23
position in a file.
Is it possible to have array kind of thing in the shell ?
a is array then
a = 123
a =... (2 Replies)
I know that directly we can assign a string to a variable but is there any other way to declare a variable as string type. I am using tcsh shell where I am using a function which would return a value of string type but when I am using return keyword , it is returning only integer value.pls help. (3 Replies)
I get an error in my shell script that line 1: )unexpected.
Line 1 in my script (using sh by the way) is the variable I declared but did not initialize it.
result=
Is this wrong? How can I fix it? I am using the variable later in the program, so I figured I could just declare it first... (4 Replies)
Is it possible to declare an array in the following way:
@tmp = (@f,"String1","String2", "String3",@f);
I'm getting the following error message:
Array found where operator expected at Program.pl line 181, near ""
(Missing semicolon on previous line?)
---------- Post updated at... (1 Reply)
Does anyone know how to declare an array in csh? I don't want to declare any elements in the array because I have a variable that represents the size of the array. For example: the array I want to declare is called sortList and it passes in the variable ARRAYSIZE that stores the value 8. (1 Reply)
Discussion started by: demet8
1 Replies
LEARN ABOUT DEBIAN
class::makemethods::template::classvar
MakeMethods::Template::ClassVar(3pm) User Contributed Perl Documentation MakeMethods::Template::ClassVar(3pm)NAME
Class::MakeMethods::Template::ClassVar - Static methods with subclass variation
SYNOPSIS
package MyObject;
use Class::MakeMethods::Template::ClassVar (
scalar => [ 'foo' ]
);
package main;
MyObject->foo('bar')
print MyObject->foo();
$MyObject::foo = 'bazillion';
print MyObject->foo();
DESCRIPTION
These meta-methods provide access to package (class global) variables, with the package determined at run-time.
This is basically the same as the PackageVar meta-methods, except that PackageVar methods find the named variable in the package that
defines the method, while ClassVar methods use the package the object is blessed into. As a result, subclasses will each store a distinct
value for a ClassVar method, but will share the same value for a PackageVar or Static method.
Common Parameters: The following parameters are defined for ClassVar meta-methods.
variable
The name of the variable to store the value in. Defaults to the same name as the method.
Standard Methods
The following methods from Generic should all be supported:
scalar
string
string_index (?)
number
boolean
bits (?)
array (*)
hash (*)
tiedhash (?)
hash_of_arrays (?)
object (?)
instance (?)
array_of_objects (?)
code (?)
code_or_scalar (?)
See Class::MakeMethods::Template::Generic for the interfaces and behaviors of these method types.
The items marked with a * above are specifically defined in this package, whereas the others are formed automatically by the interaction of
this package's generic settings with the code templates provided by the Generic superclass.
The items marked with a ? above have not been tested sufficiently; please inform the author if they do not function as you would expect.
vars
This rewrite rule converts package variable names into ClassVar methods of the equivalent data type.
Here's an example declaration:
package MyClass;
use Class::MakeMethods::Template::ClassVar (
vars => '$VERSION @ISA'
);
MyClass now has methods that get and set the contents of its $MyClass::VERSION and @MyClass::ISA package variables:
MyClass->VERSION( 2.4 );
MyClass->push_ISA( 'Exporter' );
Subclasses can use these methods to adjust their own variables:
package MySubclass;
MySubclass->MyClass::push_ISA( 'MyClass' );
MySubclass->VERSION( 1.0 );
perl v5.10.1 2004-09-06 MakeMethods::Template::ClassVar(3pm)