Help!!! CPP program

8 views
Skip to first unread message

Vivek Vijayan

unread,
Oct 10, 2012, 9:14:17 AM10/10/12
to cmc_b...@googlegroups.com
Can anyone tell what is wrong with this program? It is giving run-time error.

--
* V *

class_inherit.cpp

Dinesh CR :)

unread,
Oct 10, 2012, 12:23:32 PM10/10/12
to cmc_b...@googlegroups.com
1st is line number 60, scanf("%f",temp_rad);

where you missed an '&' symbol......

Vivek Vijayan

unread,
Oct 10, 2012, 12:29:08 PM10/10/12
to cmc_b...@googlegroups.com
ya.. i already did notice that.. anyway thanks man. n also CPP doesnt support constructor chaining ( whereas c# does). so i had to move it to a seperate funtion n define it outside :)

On Wed, Oct 10, 2012 at 9:53 PM, Dinesh CR :) <cmcba...@gmail.com> wrote:
1st is line number 60, scanf("%f",temp_rad);

where you missed an '&' symbol......

--
 
 



--
* V *

Dinesh CR :)

unread,
Oct 10, 2012, 12:35:24 PM10/10/12
to cmc_b...@googlegroups.com
2. in line #46, your calling of Circle constructor is invoking the destructor even....

so, this would better work(for lines 44 to 49)

Circle::Circle(float rad) : m_rad(rad),
m_dia(2 * rad),
m_circumference(DEF_CIRCUM),
m_area(DEF_AREA)
{
//Circle();
//m_rad=rad;
printf("\nCircle --- Parameterized Constructor...");
}//Parameterized Constructor for class Circle

Dinesh CR :)

unread,
Oct 10, 2012, 12:37:56 PM10/10/12
to cmc_b...@googlegroups.com
Good!!! n know wat! your a Genius!! (Coz u were talking sorts of stuff like coustructor chaining, c# , blah blah, n believe me, those went way above my head :D)

Gudnyt manh!! :)

Vivek Vijayan

unread,
Oct 10, 2012, 12:43:12 PM10/10/12
to cmc_b...@googlegroups.com
but does this chaining of constructors work? it doesnt buddy.. u cant call a constructor from another constructor of same class. thats constructor chaining n CPP doesnt support it.

anyway i got my whole program re-framed.. having stint with inheritance n abstract classes now :D

--
 
 



--
* V *

Vivek Vijayan

unread,
Oct 10, 2012, 12:44:27 PM10/10/12
to cmc_b...@googlegroups.com
oops.. i didnt notice u have commented the invoking of Circle constructor from within the parameterized circle constructor.. lol
--
* V *

Vivek Vijayan

unread,
Oct 10, 2012, 12:48:44 PM10/10/12
to cmc_b...@googlegroups.com
na dude.. i had this doubt since we were learning constructors.. every time i try invoking one constructor inside other constructor, it didnt work... ( n i tried it bcoz what we were coding had some redundant codes)... n then i had to do a little research why it didnt work.. n thats how i knew about it.. nothing more.. n everyone knows who is the so-called 'Genius' here :D
--
* V *

Dinesh Kumar

unread,
Oct 10, 2012, 12:48:39 PM10/10/12
to cmc_b...@googlegroups.com
I think it works, i mean the very said "constructor Chaining", having
an object created for a class. In your program we have just been using
the smoke test!! Also the smoketest, i guess, should be of 'static'
type!!

Dinesh Kumar

unread,
Oct 10, 2012, 12:51:39 PM10/10/12
to cmc_b...@googlegroups.com
haha!! We better don't abt ppl (whom you said 'Genius') who r not a
part of this discusion now :D

Vivek Vijayan

unread,
Oct 10, 2012, 12:58:44 PM10/10/12
to cmc_b...@googlegroups.com
ah.. lemme specify then.. C.R Dinesh is a genius.. n i must take this opportunity to say that he is also 'The Guy' who own a company of his own..  :D

gunnyte buddies.. sorry for bugging you all :D

On Wed, Oct 10, 2012 at 10:21 PM, Dinesh Kumar <lunati...@gmail.com> wrote:
haha!! We better don't abt ppl (whom you said 'Genius') who r not a
part of this discusion now :D

--





--
* V *

Dinesh Kumar

unread,
Oct 10, 2012, 2:28:10 PM10/10/12
to cmc_b...@googlegroups.com
Now dat's way toooooo Insane dude!!! n accept it I R NOT a genius! :P

n yeah sorry people! :D
Reply all
Reply to author
Forward
0 new messages