cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
UNIX/Linux Programming
structure construtctor
structure construtctor
Apr 25, 2012 at 3:51pm UTC
muralicplus
(3)
struct buf
{
int a;
buf(){
cout<<"in stuct default\n";
a = 3;
}
buf(int x) {
a = x;
cout<<"in stuct parameterizd\n";
}
};
int main()
{
1---> struct buf o3;
2---> struct buf o4();
}
While executing (1), i got the print "in stuct default", where as for {2), its not the like that.what is the difference between line (1) & (2)
Thanks in advance
Murali
Apr 25, 2012 at 5:02pm UTC
ne555
(10692)
The parenthesis. You are declaring a function called o4 that returns a buf and doesn't take parameters.
Apr 26, 2012 at 7:31am UTC
muralicplus
(3)
Thanks for your reply, i just got confused with Java style of invoking a contructor
Topic archived. No new replies allowed.