09-05-2006
Constructor problem
Hi guys I am new to these forums but since I am taking a class at college I would appreciate any help that is possible for this program. My instructor said that when its complete the program should be able to store all 3 fields instead of just 1.
public class Greeter2Test
{
public static void main( String[] args)
{
Greeter terse = new Greeter ( "Hello, ", "Goodbye, ", "Dave" );
Greeter verbose = new Greeter ("How are you, ", "Have a nice day, ", "Hal");
System.out.println( terse.sayHello() );
System.out.println( verbose.sayHello() );
System.out.println( verbose.sayGoodbye() );
System.out.println( terse.sayGoodbye() );
}
}
Im not sure what it is that I am supposed to edit to make it work properly
The error I get is cannot find symbol. But I cant see which symbol it means or what exactly it is that I am misssing any help would be most appreciated.
7 More Discussions You Might Find Interesting
1. Programming
helo i read many books but i cant find the proper answer that why
constructor cannot be virtual
can u explain me in simple term that why constructor cannot be virtual
Regards,
Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies
2. Programming
helo i m new in c++ on linux
can u tell me with an simple example that how do you handle constructor and destructor that fail?
Regards,
Amit (4 Replies)
Discussion started by: amitpansuria
4 Replies
3. Shell Programming and Scripting
Hi,
Is it possible to call the constructur of a java class in a shell script?
I know you can call static methods, but can you also call the constructor?
tnx. (1 Reply)
Discussion started by: thebladerunner
1 Replies
4. Programming
Hi All,
I have made the simple following program :-
#include <string>
#include <iostream>
using namespace std;
class A{
private: int val;
public :
A(){cout<<"In A()"<<endl;}
A (const A& aa)
{
cout<<"In copy c'tor"<<endl;
}
};
A f(... (1 Reply)
Discussion started by: shubhranshu
1 Replies
5. Programming
I have the following code
class Param{
public:
Param(int aa, int bb){
a=aa;
b=bb;
}
int a,b;
};
void function(Param);
int main(){
function(2,3);
return 0;
} (6 Replies)
Discussion started by: santiagorf
6 Replies
6. Programming
Hi,
If I run the following program
class A {
public:
A() { cout << "default" << endl; }
A(const A&) { cout << "copy" << endl; }
};
A tmp;
A fun() {
return tmp;
}
A test() {
A tmp;
cout << &tmp << endl;
return tmp;
} (1 Reply)
Discussion started by: royalibrahim
1 Replies
7. Programming
I am learning about C++ and today am reading concepts for Constructor but it seems a bit difficult to grab it fully. Please anyone explain in simple words about Constructor? (1 Reply)
Discussion started by: ggiwebsinfo
1 Replies
STAPEX(3stap) STAPEX(3stap)
NAME
stapex - systemtap examples
LANGUAGE BASICS
These examples give a feel for basic systemtap syntax and control structures.
global odds, evens
probe begin {
# "no" and "ne" are local integers
for (i=0; i<10; i++) {
if (i % 2) odds [no++] = i
else evens [ne++] = i
}
delete odds[2]
delete evens[3]
exit ()
}
probe end {
foreach (x+ in odds) {
printf ("odds[%d] = %d0, x, odds[x])
}
foreach (x in evens-) {
printf ("evens[%d] = %d0, x, evens[x])
}
}
This prints:
odds[1] = 1
odds[3] = 5
odds[4] = 7
odds[5] = 9
evens[5] = 8
evens[4] = 6
evens[2] = 2
evens[1] = 0
Note that all variables types are inferred, and that all locals and globals are automatically initialized.
This script prints the primes between 0 and 49.
function isprime (x) {
if (x < 2) return 0
for (i=2; i<x; i++) {
if (x % i == 0) return 0
if (i * i > x) break
}
return 1
}
probe begin {
for (i=0; i<50; i++)
if (isprime (i)) printf("%d0, i)
exit()
}
This script demonstrates recursive functions.
function fibonacci(i) {
if (i < 1) error ("bad number")
if (i == 1) return 1
if (i == 2) return 2
return fibonacci (i-1) + fibonacci (i-2)
}
probe begin {
printf ("11th fibonacci number: %d0, fibonacci(11))
exit ()
}
Any larger number may exceed the MAXACTION or MAXNESTING limits, and result in an error.
PROBING
To trace entry and exit from a function, use a pair of probes:
probe kernel.function("sys_mkdir") { println ("enter") }
probe kernel.function("sys_mkdir").return { println ("exit") }
To list the probeable functions in the kernel, use the listings mode.
% stap -l 'kernel.function("*")'
To list the probeable functions and local variables in the kernel, use another listings mode.
% stap -L 'kernel.function("*")'
MORE EXAMPLES
The directory to find more examples can be found in the stappaths(7) manual page.
SEE ALSO
stap(1) stapprobes(3stap) stapfuncs(3stap) stappaths(7)
STAPEX(3stap)