Hello aravind ,
I tried to compile the program using Visual C++ 64 bit edition and I could
not compile the original program . I tried
your suggestion of putting extra parenthesis , still it did not compile.
Did it get compiled with GCC ?
@All
sizeof is a compile time unary operator. It does not have any effect at the
run time. The class written here
do not have any instance variable.
What will be the size of a class with no instance variable ? ( I will put a
follow up question after this )
This was a favorite interview question of 1990s !
regards
Praseed Pai
________________________________
From: aravind vijayan <[email protected]>
To: [email protected]
Sent: Monday, October 24, 2011 7:09 PM
Subject: [ILUG-Cochin.org] CPP constructor...
HI,
Let me post a replay for a small discussion on last meeting:
# include <iostream>
using std::cout;
class abc
{
public:
abc(){cout<<"In abc";}
};
class xyz
{
public:
xyz(abc x)
{cout<<"In xyz";}
void show(){cout<<"In show";}
};
int main()
{
xyz obj(abc());
obj.show();
return 0;
}
here we declaring a function via:xyz obj(abc());
you can find it your self by using sizeof operator...
to make obj an object you will have to add ()
as:
xyz obj((abc()));
it will treated as object creation...
Registered Linux user #545296
_______________________________________________
Indian Libre User Group Cochin Mailing List
http://www.ilug-cochin.org/mailing-list/
http://mail.ilug-cochin.org/mailman/listinfo/mailinglist_ilug-cochin.org
#[email protected]_______________________________________________
Indian Libre User Group Cochin Mailing List
http://www.ilug-cochin.org/mailing-list/
http://mail.ilug-cochin.org/mailman/listinfo/mailinglist_ilug-cochin.org
#[email protected]