-
What do you think constructor can return a value i.e "0(void)" or constructor can never return return a value???0
-
Member • Aug 18, 2010
A constructor can never return a value, it hasn't got any return type.Are you sure? This action cannot be undone. -
Member • Aug 18, 2010
Correct gaurav constructor can never return any valu.
like this
public class r
{
int p;
public void r(int k)//Show an error because here constructor should return a valu that is "0"(void);
{
p=k;
System.out.println("p= "+p);
}
public static void main(String args[])
{
r t=new r(5);
}
}Are you sure? This action cannot be undone. -
Administrator • Aug 18, 2010
Thread moved to CS/IT Engineering section.Are you sure? This action cannot be undone. -
Member • Aug 18, 2010
I answered with reference to C++, not sure about other OO languages though.mohit007kumar00Correct gaurav constructor can never return any valu.
like thisAre you sure? This action cannot be undone. -
Member • Aug 18, 2010
@Gaurav same here in the case of java also gaurav.Are you sure? This action cannot be undone. -
Member • Aug 20, 2010
hello everyone,
System.out.println("the value of c is="+c);
as we know here that here +sign appends the value of c to the string which preceids it i.e if the value of c is in the form of integer the firstly it is being converted to string.why is it so??
can anyone please justify that for me????Are you sure? This action cannot be undone. -
Member • Aug 21, 2010
@anand here in java "+" is an operator which is used to add or concatenate two strings objects that's why c is converted to string.Are you sure? This action cannot be undone. -
Member • Aug 24, 2010
You fellas are much more up to date with this stuff than me, but thinking back to Pascal...
p = ^t;
t = type
constructor init;
destructor done; virtual;
end; {type}
if new(p,init()) <> nil then...
So, I think the constructor returns a pointer if successful and nil when not.
Any better ideas?Are you sure? This action cannot be undone.